pub trait Headers {
// Required methods
fn add_with_header(
&mut self,
header: RecordHeader,
) -> Result<(), LocalIllegalStateError>;
fn add_with_key_value(
&mut self,
key: &str,
value: Option<&[u8]>,
) -> Result<(), LocalIllegalStateError>;
fn remove(&mut self, key: &str) -> Result<(), LocalIllegalStateError>;
fn last_header(&self, key: &str) -> Option<&RecordHeader>;
fn headers(&self, key: &str) -> Vec<&RecordHeader>;
fn to_array(&self) -> &[RecordHeader];
fn iter(&self) -> Iter<'_, RecordHeader>;
}Expand description
A mutable ordered collection of Header objects. Note that multiple headers may have the same
key.
The order of headers is preserved in the order they were added.
Required Methods§
Sourcefn add_with_header(
&mut self,
header: RecordHeader,
) -> Result<(), LocalIllegalStateError>
fn add_with_header( &mut self, header: RecordHeader, ) -> Result<(), LocalIllegalStateError>
Adds a header (key inside), to the end, returning if the operation succeeded.
§Arguments
header- the Header to be added.
§Errors
Error::is_local_illegal_state_errorif headers are in a read-only state.
Sourcefn add_with_key_value(
&mut self,
key: &str,
value: Option<&[u8]>,
) -> Result<(), LocalIllegalStateError>
fn add_with_key_value( &mut self, key: &str, value: Option<&[u8]>, ) -> Result<(), LocalIllegalStateError>
Creates and adds a header, to the end, returning if the operation succeeded.
§Arguments
key- of the header to be added.value- of the header to be added; may beNone.
§Errors
Error::is_local_illegal_state_errorif headers are in a read-only state.
§Translation notes
The key and value are borrowed and copied into the new header.
Sourcefn remove(&mut self, key: &str) -> Result<(), LocalIllegalStateError>
fn remove(&mut self, key: &str) -> Result<(), LocalIllegalStateError>
Removes all headers for the given key returning if the operation succeeded, while preserving the insertion order of the remaining headers.
§Arguments
key- to remove all headers for.
§Errors
Error::is_local_illegal_state_errorif headers are in a read-only state.
Sourcefn last_header(&self, key: &str) -> Option<&RecordHeader>
fn last_header(&self, key: &str) -> Option<&RecordHeader>
Sourcefn headers(&self, key: &str) -> Vec<&RecordHeader>
fn headers(&self, key: &str) -> Vec<&RecordHeader>
Sourcefn to_array(&self) -> &[RecordHeader]
fn to_array(&self) -> &[RecordHeader]
Returns all headers as a slice, in the order they were added in.
§Returns
the headers, if NO headers are present an empty slice is returned.
Sourcefn iter(&self) -> Iter<'_, RecordHeader>
fn iter(&self) -> Iter<'_, RecordHeader>
Returns an iterator over the headers.