pub struct Decoder<'a> { /* private fields */ }
Expand description
Provides the decoding engine for HTTP/2 headers.
Implementations§
Source§impl<'a> Decoder<'a>
impl<'a> Decoder<'a>
Sourcepub const WITH_INDEXING: u8 = 4u8
pub const WITH_INDEXING: u8 = 4u8
A flag indicating that a new header entry has been inserted into the indexing table ([6.2.1.]).
Sourcepub const NEVER_INDEXED: u8 = 8u8
pub const NEVER_INDEXED: u8 = 8u8
A flag indicating a sensitive header field ([6.2.3.]).
Sourcepub fn with_dynamic_size(max_dynamic_size: u32) -> Self
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.
Sourcepub fn max_dynamic_size(&self) -> u32
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.
Sourcepub fn set_max_dynamic_size(&mut self, size: u32)
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.
Sourcepub fn decode(
&mut self,
buf: &mut Vec<u8>,
dst: &mut Vec<(Vec<u8>, Vec<u8>, u8)>,
) -> Result<usize, DecoderError>
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.
Sourcepub fn decode_exact(
&mut self,
buf: &mut Vec<u8>,
dst: &mut Vec<(Vec<u8>, Vec<u8>, u8)>,
) -> Result<usize, DecoderError>
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.