Struct Decoder

Source
pub struct Decoder<'a> { /* private fields */ }
Expand description

Provides the decoding engine for HTTP/2 headers.

Implementations§

Source§

impl<'a> Decoder<'a>

Source

pub const WITH_INDEXING: u8 = 4u8

A flag indicating that a new header entry has been inserted into the indexing table ([6.2.1.]).

Source

pub const NEVER_INDEXED: u8 = 8u8

A flag indicating a sensitive header field ([6.2.3.]).

Source

pub fn with_dynamic_size(max_dynamic_size: u32) -> Self

Returns a new decoder instance with a desired maximum allowed size of the dynamic table.

Source

pub fn max_dynamic_size(&self) -> u32

Returns the maximum allowed size of the dynamic table.

Note that the dynamic table could actually be of different size. This size is just a hard limit set by the external protocol.

Source

pub fn set_max_dynamic_size(&mut self, size: u32)

Sets the maximum allowed size of the dynamic table.

This size is just a hard limit that should be set by the external protocol. Changing the size will not change the size of the actual underlaying table. The table will be updated through the size update signal when decoding.

Source

pub fn decode( &mut self, buf: &mut Vec<u8>, dst: &mut Vec<(Vec<u8>, Vec<u8>, u8)>, ) -> Result<usize, DecoderError>

Decodes headers provided in HPACK’s header field representation format.

The functions consumes the buf of bytes and writes header results to dst. Each item contains header name, value and flags. The decoder will not index fields unless 0x4 flag is returned. When the 0x8 flag is present, the header field should be treated with caution.

Example:

use httlib_hpack::Decoder;
 
let mut decoder = Decoder::default();
let mut dst = Vec::new();
let mut buf = vec![0x80 | 2];
decoder.decode(&mut buf, &mut dst).unwrap();

This function consumes the buffer only if the decoding succeeds. The provided vector will stay untouched in case of an error.

Source

pub fn decode_exact( &mut self, buf: &mut Vec<u8>, dst: &mut Vec<(Vec<u8>, Vec<u8>, u8)>, ) -> Result<usize, DecoderError>

Decodes the exact number of headers from the provided HPACK’s sequence, based on the available vector capacity.

The functions consumes the buf of bytes and writes header results to dst. Each item contains header name, value and flags. The decoder will not index fields unless 0x4 flag is returned. When the 0x8 flag is present, the header field should be treated with caution.

Example:

use httlib_hpack::Decoder;
 
let mut decoder = Decoder::default();
let mut dst = Vec::with_capacity(2);
let mut buf = vec![0x80 | 2, 0x80 | 3];
decoder.decode_exact(&mut buf, &mut dst).unwrap();

This function consumes the buffer only if the decoding succeeds. The provided vector will stay untouched in case of an error.

Trait Implementations§

Source§

impl<'a> Debug for Decoder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Decoder<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Decoder<'a>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.