[][src]Trait hyperx::header::TypedHeaders

pub trait TypedHeaders {
    fn decode<H>(&self) -> Result<H>
    where
        H: StandardHeader
;
fn try_decode<H>(&self) -> Option<Result<H>>
    where
        H: StandardHeader
;
fn encode<H>(&mut self, value: &H)
    where
        H: StandardHeader + Display
;
fn encode_append<H>(&mut self, value: &H)
    where
        H: StandardHeader + Display
; }

Extension trait for decode (parsing) and encode (serialization) of typed headers from/to a collection of headers such as HeaderMap.

Required methods

fn decode<H>(&self) -> Result<H> where
    H: StandardHeader

Decode and return Header type H or Error::Header.

Error::Header is returned on failed parse, or for a single-valued Header type, if no values or multiple values are found in the collection. Multi-valued header types such as ContentEncoding will instead return an empty list value if no values are found. To distinguish the not found case, use try_decode instead.

fn try_decode<H>(&self) -> Option<Result<H>> where
    H: StandardHeader

Decode and return Header type H or Error::Header if found, or return None if not found.

This variant will return Option::None if no header with the associated key (HeaderName) is found in the collection. If the collection does contain such a key, it will return the header type H or Error::Header.

fn encode<H>(&mut self, value: &H) where
    H: StandardHeader + Display

Encode and write the specified typed header value in the collection.

Uses the Display format of the provided header value to write a single header. This will overwrite any preexisting values with the same key (HeaderName). Use encode_append instead to avoid this.

fn encode_append<H>(&mut self, value: &H) where
    H: StandardHeader + Display

Encode and append the specified typed header value into the collection.

Uses the Display format of the provided header value to append a single header. If the collection previously had a value for the same key, the additional value is appended to the end.

Loading content...

Implementations on Foreign Types

impl TypedHeaders for HeaderMap[src]

Loading content...

Implementors

Loading content...