pub trait HostFields {
// Required methods
fn new(&mut self) -> Result<Resource<Fields>>;
fn from_list(
&mut self,
entries: Vec<(FieldKey, FieldValue)>,
) -> Result<Result<Resource<Fields>, HeaderError>>;
fn get(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
) -> Result<Vec<FieldValue>>;
fn has(&mut self, self_: Resource<Fields>, name: FieldKey) -> Result<bool>;
fn set(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
value: Vec<FieldValue>,
) -> Result<Result<(), HeaderError>>;
fn delete(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
) -> Result<Result<(), HeaderError>>;
fn append(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
value: FieldValue,
) -> Result<Result<(), HeaderError>>;
fn entries(
&mut self,
self_: Resource<Fields>,
) -> Result<Vec<(FieldKey, FieldValue)>>;
fn clone(&mut self, self_: Resource<Fields>) -> Result<Resource<Fields>>;
fn drop(&mut self, rep: Resource<Fields>) -> Result<()>;
}
Required Methods§
Sourcefn new(&mut self) -> Result<Resource<Fields>>
fn new(&mut self) -> Result<Resource<Fields>>
Construct an empty HTTP Fields.
The resulting fields
is mutable.
Sourcefn from_list(
&mut self,
entries: Vec<(FieldKey, FieldValue)>,
) -> Result<Result<Resource<Fields>, HeaderError>>
fn from_list( &mut self, entries: Vec<(FieldKey, FieldValue)>, ) -> Result<Result<Resource<Fields>, HeaderError>>
Construct an HTTP Fields.
The resulting fields
is mutable.
The list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key.
The tuple is a pair of the field key, represented as a string, and Value, represented as a list of bytes.
An error result will be returned if any field-key
or field-value
is
syntactically invalid, or if a field is forbidden.
Sourcefn get(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
) -> Result<Vec<FieldValue>>
fn get( &mut self, self_: Resource<Fields>, name: FieldKey, ) -> Result<Vec<FieldValue>>
Get all of the values corresponding to a key. If the key is not present
in this fields
or is syntactically invalid, an empty list is returned.
However, if the key is present but empty, this is represented by a list
with one or more empty field-values present.
Sourcefn has(&mut self, self_: Resource<Fields>, name: FieldKey) -> Result<bool>
fn has(&mut self, self_: Resource<Fields>, name: FieldKey) -> Result<bool>
Returns true
when the key is present in this fields
. If the key is
syntactically invalid, false
is returned.
Sourcefn set(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
value: Vec<FieldValue>,
) -> Result<Result<(), HeaderError>>
fn set( &mut self, self_: Resource<Fields>, name: FieldKey, value: Vec<FieldValue>, ) -> Result<Result<(), HeaderError>>
Set all of the values for a key. Clears any existing values for that key, if they have been set.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-key
or any of
the field-value
s are syntactically invalid.
Sourcefn delete(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
) -> Result<Result<(), HeaderError>>
fn delete( &mut self, self_: Resource<Fields>, name: FieldKey, ) -> Result<Result<(), HeaderError>>
Delete all values for a key. Does nothing if no values for the key exist.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-key
is
syntactically invalid.
Sourcefn append(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
value: FieldValue,
) -> Result<Result<(), HeaderError>>
fn append( &mut self, self_: Resource<Fields>, name: FieldKey, value: FieldValue, ) -> Result<Result<(), HeaderError>>
Append a value for a key. Does not change or delete any existing values for that key.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-key
or
field-value
are syntactically invalid.
Sourcefn entries(
&mut self,
self_: Resource<Fields>,
) -> Result<Vec<(FieldKey, FieldValue)>>
fn entries( &mut self, self_: Resource<Fields>, ) -> Result<Vec<(FieldKey, FieldValue)>>
Retrieve the full set of keys and values in the Fields. Like the constructor, the list represents each key-value pair.
The outer list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key.
Sourcefn clone(&mut self, self_: Resource<Fields>) -> Result<Resource<Fields>>
fn clone(&mut self, self_: Resource<Fields>) -> Result<Resource<Fields>>
Make a deep copy of the Fields. Equivalent in behavior to calling the
fields
constructor on the return value of entries
. The resulting
fields
is mutable.
fn drop(&mut self, rep: Resource<Fields>) -> Result<()>
Implementations on Foreign Types§
Source§impl<_T: HostFields + ?Sized + Send> HostFields for &mut _T
impl<_T: HostFields + ?Sized + Send> HostFields for &mut _T
Source§fn new(&mut self) -> Result<Resource<Fields>>
fn new(&mut self) -> Result<Resource<Fields>>
Construct an empty HTTP Fields.
The resulting fields
is mutable.
Source§fn from_list(
&mut self,
entries: Vec<(FieldKey, FieldValue)>,
) -> Result<Result<Resource<Fields>, HeaderError>>
fn from_list( &mut self, entries: Vec<(FieldKey, FieldValue)>, ) -> Result<Result<Resource<Fields>, HeaderError>>
Construct an HTTP Fields.
The resulting fields
is mutable.
The list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key.
The tuple is a pair of the field key, represented as a string, and Value, represented as a list of bytes.
An error result will be returned if any field-key
or field-value
is
syntactically invalid, or if a field is forbidden.
Source§fn get(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
) -> Result<Vec<FieldValue>>
fn get( &mut self, self_: Resource<Fields>, name: FieldKey, ) -> Result<Vec<FieldValue>>
Get all of the values corresponding to a key. If the key is not present
in this fields
or is syntactically invalid, an empty list is returned.
However, if the key is present but empty, this is represented by a list
with one or more empty field-values present.
Source§fn has(&mut self, self_: Resource<Fields>, name: FieldKey) -> Result<bool>
fn has(&mut self, self_: Resource<Fields>, name: FieldKey) -> Result<bool>
Returns true
when the key is present in this fields
. If the key is
syntactically invalid, false
is returned.
Source§fn set(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
value: Vec<FieldValue>,
) -> Result<Result<(), HeaderError>>
fn set( &mut self, self_: Resource<Fields>, name: FieldKey, value: Vec<FieldValue>, ) -> Result<Result<(), HeaderError>>
Set all of the values for a key. Clears any existing values for that key, if they have been set.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-key
or any of
the field-value
s are syntactically invalid.
Source§fn delete(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
) -> Result<Result<(), HeaderError>>
fn delete( &mut self, self_: Resource<Fields>, name: FieldKey, ) -> Result<Result<(), HeaderError>>
Delete all values for a key. Does nothing if no values for the key exist.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-key
is
syntactically invalid.
Source§fn append(
&mut self,
self_: Resource<Fields>,
name: FieldKey,
value: FieldValue,
) -> Result<Result<(), HeaderError>>
fn append( &mut self, self_: Resource<Fields>, name: FieldKey, value: FieldValue, ) -> Result<Result<(), HeaderError>>
Append a value for a key. Does not change or delete any existing values for that key.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-key
or
field-value
are syntactically invalid.
Source§fn entries(
&mut self,
self_: Resource<Fields>,
) -> Result<Vec<(FieldKey, FieldValue)>>
fn entries( &mut self, self_: Resource<Fields>, ) -> Result<Vec<(FieldKey, FieldValue)>>
Retrieve the full set of keys and values in the Fields. Like the constructor, the list represents each key-value pair.
The outer list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key.
Source§fn clone(&mut self, self_: Resource<Fields>) -> Result<Resource<Fields>>
fn clone(&mut self, self_: Resource<Fields>) -> Result<Resource<Fields>>
Make a deep copy of the Fields. Equivalent in behavior to calling the
fields
constructor on the return value of entries
. The resulting
fields
is mutable.