[][src]Struct hpack::decoder::Decoder

pub struct Decoder<'a> { /* fields omitted */ }

Decodes headers encoded using HPACK.

For now, incremental decoding is not supported, i.e. it is necessary to pass in the entire encoded representation of all headers to the decoder, rather than processing it piece-by-piece.

Implementations

impl<'a> Decoder<'a>[src]

Represents a decoder of HPACK encoded headers. Maintains the state necessary to correctly decode subsequent HPACK blocks.

pub fn new() -> Decoder<'a>[src]

Creates a new Decoder with all settings set to default values.

pub fn set_max_table_size(&mut self, new_max_size: usize)[src]

Sets a new maximum dynamic table size for the decoder.

pub fn decode_with_cb<F>(
    &mut self,
    buf: &[u8],
    cb: F
) -> Result<(), DecoderError> where
    F: FnMut(Cow<[u8]>, Cow<[u8]>), 
[src]

Decodes the headers found in the given buffer buf. Invokes the callback cb for each decoded header in turn, by providing it the header name and value as Cow byte array slices.

The callback is free to decide how to handle the emitted header, however the Cow cannot outlive the closure body without assuming ownership or otherwise copying the contents.

This is due to the fact that the header might be found (fully or partially) in the header table of the decoder, in which case the callback will have received a borrow of its contents. However, when one of the following headers is decoded, it is possible that the header table might have to be modified; so the borrow is only valid until the next header decoding begins, meaning until the end of the callback's body.

If an error is encountered during the decoding of any header, decoding halts and the appropriate error is returned as the Err variant of the Result.

pub fn decode(&mut self, buf: &[u8]) -> DecoderResult[src]

Decode the header block found in the given buffer.

The decoded representation is returned as a sequence of headers, where both the name and value of each header is represented by an owned byte sequence (i.e. Vec<u8>).

The buffer should represent the entire block that should be decoded. For example, in HTTP/2, all continuation frames need to be concatenated to a single buffer before passing them to the decoder.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Decoder<'a>

impl<'a> Send for Decoder<'a>

impl<'a> Sync for Decoder<'a>

impl<'a> Unpin for Decoder<'a>

impl<'a> UnwindSafe for Decoder<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.