pub trait HostFields: Sized + Send {
// Required methods
fn new(&mut self) -> Result<Resource<Fields>>;
fn from_list(
&mut self,
entries: Vec<(FieldName, FieldValue)>,
) -> Result<Result<Resource<Fields>, HeaderError>>;
fn get(
&mut self,
self_: Resource<Fields>,
name: FieldName,
) -> Result<Vec<FieldValue>>;
fn has(&mut self, self_: Resource<Fields>, name: FieldName) -> Result<bool>;
fn set(
&mut self,
self_: Resource<Fields>,
name: FieldName,
value: Vec<FieldValue>,
) -> Result<Result<(), HeaderError>>;
fn delete(
&mut self,
self_: Resource<Fields>,
name: FieldName,
) -> Result<Result<(), HeaderError>>;
fn append(
&mut self,
self_: Resource<Fields>,
name: FieldName,
value: FieldValue,
) -> Result<Result<(), HeaderError>>;
fn entries(
&mut self,
self_: Resource<Fields>,
) -> Result<Vec<(FieldName, 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<(FieldName, FieldValue)>,
) -> Result<Result<Resource<Fields>, HeaderError>>
fn from_list( &mut self, entries: Vec<(FieldName, FieldValue)>, ) -> Result<Result<Resource<Fields>, HeaderError>>
Construct an HTTP Fields.
The resulting fields
is mutable.
The list represents each name-value pair in the Fields. Names which have multiple values are represented by multiple entries in this list with the same name.
The tuple is a pair of the field name, represented as a string, and Value, represented as a list of bytes.
An error result will be returned if any field-name
or field-value
is
syntactically invalid, or if a field is forbidden.
Sourcefn get(
&mut self,
self_: Resource<Fields>,
name: FieldName,
) -> Result<Vec<FieldValue>>
fn get( &mut self, self_: Resource<Fields>, name: FieldName, ) -> Result<Vec<FieldValue>>
Get all of the values corresponding to a name. If the name is not present
in this fields
or is syntactically invalid, an empty list is returned.
However, if the name 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: FieldName) -> Result<bool>
fn has(&mut self, self_: Resource<Fields>, name: FieldName) -> Result<bool>
Returns true
when the name is present in this fields
. If the name is
syntactically invalid, false
is returned.
Sourcefn set(
&mut self,
self_: Resource<Fields>,
name: FieldName,
value: Vec<FieldValue>,
) -> Result<Result<(), HeaderError>>
fn set( &mut self, self_: Resource<Fields>, name: FieldName, value: Vec<FieldValue>, ) -> Result<Result<(), HeaderError>>
Set all of the values for a name. Clears any existing values for that name, if they have been set.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-name
or any of
the field-value
s are syntactically invalid.
Sourcefn delete(
&mut self,
self_: Resource<Fields>,
name: FieldName,
) -> Result<Result<(), HeaderError>>
fn delete( &mut self, self_: Resource<Fields>, name: FieldName, ) -> Result<Result<(), HeaderError>>
Delete all values for a name. Does nothing if no values for the name exist.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-name
is
syntactically invalid.
Sourcefn append(
&mut self,
self_: Resource<Fields>,
name: FieldName,
value: FieldValue,
) -> Result<Result<(), HeaderError>>
fn append( &mut self, self_: Resource<Fields>, name: FieldName, value: FieldValue, ) -> Result<Result<(), HeaderError>>
Append a value for a name. Does not change or delete any existing values for that name.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-name
or
field-value
are syntactically invalid.
Sourcefn entries(
&mut self,
self_: Resource<Fields>,
) -> Result<Vec<(FieldName, FieldValue)>>
fn entries( &mut self, self_: Resource<Fields>, ) -> Result<Vec<(FieldName, FieldValue)>>
Retrieve the full set of names and values in the Fields. Like the constructor, the list represents each name-value pair.
The outer list represents each name-value pair in the Fields. Names which have multiple values are represented by multiple entries in this list with the same name.
The names and values are always returned in the original casing and in the order in which they will be serialized for transport.
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<()>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
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<(FieldName, FieldValue)>,
) -> Result<Result<Resource<Fields>, HeaderError>>
fn from_list( &mut self, entries: Vec<(FieldName, FieldValue)>, ) -> Result<Result<Resource<Fields>, HeaderError>>
Construct an HTTP Fields.
The resulting fields
is mutable.
The list represents each name-value pair in the Fields. Names which have multiple values are represented by multiple entries in this list with the same name.
The tuple is a pair of the field name, represented as a string, and Value, represented as a list of bytes.
An error result will be returned if any field-name
or field-value
is
syntactically invalid, or if a field is forbidden.
Source§fn get(
&mut self,
self_: Resource<Fields>,
name: FieldName,
) -> Result<Vec<FieldValue>>
fn get( &mut self, self_: Resource<Fields>, name: FieldName, ) -> Result<Vec<FieldValue>>
Get all of the values corresponding to a name. If the name is not present
in this fields
or is syntactically invalid, an empty list is returned.
However, if the name 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: FieldName) -> Result<bool>
fn has(&mut self, self_: Resource<Fields>, name: FieldName) -> Result<bool>
Returns true
when the name is present in this fields
. If the name is
syntactically invalid, false
is returned.
Source§fn set(
&mut self,
self_: Resource<Fields>,
name: FieldName,
value: Vec<FieldValue>,
) -> Result<Result<(), HeaderError>>
fn set( &mut self, self_: Resource<Fields>, name: FieldName, value: Vec<FieldValue>, ) -> Result<Result<(), HeaderError>>
Set all of the values for a name. Clears any existing values for that name, if they have been set.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-name
or any of
the field-value
s are syntactically invalid.
Source§fn delete(
&mut self,
self_: Resource<Fields>,
name: FieldName,
) -> Result<Result<(), HeaderError>>
fn delete( &mut self, self_: Resource<Fields>, name: FieldName, ) -> Result<Result<(), HeaderError>>
Delete all values for a name. Does nothing if no values for the name exist.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-name
is
syntactically invalid.
Source§fn append(
&mut self,
self_: Resource<Fields>,
name: FieldName,
value: FieldValue,
) -> Result<Result<(), HeaderError>>
fn append( &mut self, self_: Resource<Fields>, name: FieldName, value: FieldValue, ) -> Result<Result<(), HeaderError>>
Append a value for a name. Does not change or delete any existing values for that name.
Fails with header-error.immutable
if the fields
are immutable.
Fails with header-error.invalid-syntax
if the field-name
or
field-value
are syntactically invalid.
Source§fn entries(
&mut self,
self_: Resource<Fields>,
) -> Result<Vec<(FieldName, FieldValue)>>
fn entries( &mut self, self_: Resource<Fields>, ) -> Result<Vec<(FieldName, FieldValue)>>
Retrieve the full set of names and values in the Fields. Like the constructor, the list represents each name-value pair.
The outer list represents each name-value pair in the Fields. Names which have multiple values are represented by multiple entries in this list with the same name.
The names and values are always returned in the original casing and in the order in which they will be serialized for transport.
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.