Skip to main content

Headers

Trait Headers 

Source
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§

Source

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
Source

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 be None.
§Errors
§Translation notes

The key and value are borrowed and copied into the new header.

Source

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
Source

fn last_header(&self, key: &str) -> Option<&RecordHeader>

Returns just one (the very last) header for the given key, if present.

§Arguments
  • key - to get the last header for.
§Returns

this last header matching the given key, returns None if not present.

Source

fn headers(&self, key: &str) -> Vec<&RecordHeader>

Returns all headers for the given key, in the order they were added in, if present.

§Arguments
  • key - to return the headers for.
§Returns

all headers for the given key, in the order they were added in, if NO headers are present an empty list is returned.

Source

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.

Source

fn iter(&self) -> Iter<'_, RecordHeader>

Returns an iterator over the headers.

Implementors§