Trait wasmtime_wasi_http::bindings::http::types::HostFields
source · 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.