Trait wasmcloud_runtime::capability::http::types::HostFields
source · pub trait HostFields {
// Required methods
fn new(&mut self) -> Result<Resource<HostFields>, Error>;
fn from_list(
&mut self,
entries: Vec<(String, Vec<u8>)>,
) -> Result<Result<Resource<HostFields>, HeaderError>, Error>;
fn get(
&mut self,
self_: Resource<HostFields>,
name: String,
) -> Result<Vec<Vec<u8>>, Error>;
fn has(
&mut self,
self_: Resource<HostFields>,
name: String,
) -> Result<bool, Error>;
fn set(
&mut self,
self_: Resource<HostFields>,
name: String,
value: Vec<Vec<u8>>,
) -> Result<Result<(), HeaderError>, Error>;
fn delete(
&mut self,
self_: Resource<HostFields>,
name: String,
) -> Result<Result<(), HeaderError>, Error>;
fn append(
&mut self,
self_: Resource<HostFields>,
name: String,
value: Vec<u8>,
) -> Result<Result<(), HeaderError>, Error>;
fn entries(
&mut self,
self_: Resource<HostFields>,
) -> Result<Vec<(String, Vec<u8>)>, Error>;
fn clone(
&mut self,
self_: Resource<HostFields>,
) -> Result<Resource<HostFields>, Error>;
fn drop(&mut self, rep: Resource<HostFields>) -> Result<(), Error>;
}
Required Methods§
sourcefn new(&mut self) -> Result<Resource<HostFields>, Error>
fn new(&mut self) -> Result<Resource<HostFields>, Error>
Construct an empty HTTP Fields.
The resulting fields
is mutable.
sourcefn from_list(
&mut self,
entries: Vec<(String, Vec<u8>)>,
) -> Result<Result<Resource<HostFields>, HeaderError>, Error>
fn from_list( &mut self, entries: Vec<(String, Vec<u8>)>, ) -> Result<Result<Resource<HostFields>, HeaderError>, Error>
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<HostFields>,
name: String,
) -> Result<Vec<Vec<u8>>, Error>
fn get( &mut self, self_: Resource<HostFields>, name: String, ) -> Result<Vec<Vec<u8>>, Error>
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<HostFields>,
name: String,
) -> Result<bool, Error>
fn has( &mut self, self_: Resource<HostFields>, name: String, ) -> Result<bool, Error>
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<HostFields>,
name: String,
value: Vec<Vec<u8>>,
) -> Result<Result<(), HeaderError>, Error>
fn set( &mut self, self_: Resource<HostFields>, name: String, value: Vec<Vec<u8>>, ) -> Result<Result<(), HeaderError>, Error>
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<HostFields>,
name: String,
) -> Result<Result<(), HeaderError>, Error>
fn delete( &mut self, self_: Resource<HostFields>, name: String, ) -> Result<Result<(), HeaderError>, Error>
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<HostFields>,
name: String,
value: Vec<u8>,
) -> Result<Result<(), HeaderError>, Error>
fn append( &mut self, self_: Resource<HostFields>, name: String, value: Vec<u8>, ) -> Result<Result<(), HeaderError>, Error>
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<HostFields>,
) -> Result<Vec<(String, Vec<u8>)>, Error>
fn entries( &mut self, self_: Resource<HostFields>, ) -> Result<Vec<(String, Vec<u8>)>, Error>
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<HostFields>,
) -> Result<Resource<HostFields>, Error>
fn clone( &mut self, self_: Resource<HostFields>, ) -> Result<Resource<HostFields>, Error>
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<HostFields>) -> Result<(), Error>
Implementations on Foreign Types§
source§impl<_T> HostFields for &mut _T
impl<_T> HostFields for &mut _T
source§fn new(&mut self) -> Result<Resource<HostFields>, Error>
fn new(&mut self) -> Result<Resource<HostFields>, Error>
Construct an empty HTTP Fields.
The resulting fields
is mutable.
source§fn from_list(
&mut self,
entries: Vec<(String, Vec<u8>)>,
) -> Result<Result<Resource<HostFields>, HeaderError>, Error>
fn from_list( &mut self, entries: Vec<(String, Vec<u8>)>, ) -> Result<Result<Resource<HostFields>, HeaderError>, Error>
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<HostFields>,
name: String,
) -> Result<Vec<Vec<u8>>, Error>
fn get( &mut self, self_: Resource<HostFields>, name: String, ) -> Result<Vec<Vec<u8>>, Error>
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<HostFields>,
name: String,
) -> Result<bool, Error>
fn has( &mut self, self_: Resource<HostFields>, name: String, ) -> Result<bool, Error>
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<HostFields>,
name: String,
value: Vec<Vec<u8>>,
) -> Result<Result<(), HeaderError>, Error>
fn set( &mut self, self_: Resource<HostFields>, name: String, value: Vec<Vec<u8>>, ) -> Result<Result<(), HeaderError>, Error>
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<HostFields>,
name: String,
) -> Result<Result<(), HeaderError>, Error>
fn delete( &mut self, self_: Resource<HostFields>, name: String, ) -> Result<Result<(), HeaderError>, Error>
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<HostFields>,
name: String,
value: Vec<u8>,
) -> Result<Result<(), HeaderError>, Error>
fn append( &mut self, self_: Resource<HostFields>, name: String, value: Vec<u8>, ) -> Result<Result<(), HeaderError>, Error>
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<HostFields>,
) -> Result<Vec<(String, Vec<u8>)>, Error>
fn entries( &mut self, self_: Resource<HostFields>, ) -> Result<Vec<(String, Vec<u8>)>, Error>
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<HostFields>,
) -> Result<Resource<HostFields>, Error>
fn clone( &mut self, self_: Resource<HostFields>, ) -> Result<Resource<HostFields>, Error>
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.