Skip to main content

Encoder

Struct Encoder 

Source
pub struct Encoder { /* private fields */ }
Expand description

The connection-level HPACK encoder of one direction.

Implementations§

Source§

impl Encoder

Source

pub const fn new() -> Self

An encoder with the default 4096-octet table. Allocates nothing.

Source

pub fn set_max_table_size(&mut self, max_size: usize)

Sets the maximum size of the table, at most the peer’s SETTINGS_HEADER_TABLE_SIZE, and evicts until it fits (§4.3). The caller signals the change to the peer with a size update (§6.3) at the start of its next block; Self::change_max_table_size records it for Self::encode_size_updates_into instead.

Source

pub fn change_max_table_size(&mut self, max_size: usize)

Sets the maximum size like Self::set_max_table_size and records the change for the size updates that open the next block (§4.2): the smallest size set since the last block, and the last one.

Source

pub fn encode_size_updates_into( &mut self, last_size: usize, out: &mut Vec<u8>, ) -> usize

Appends the size updates (§6.3) that open a block after the maximum size changed to last_size, and forgets the changes recorded by Self::change_max_table_size.

When the size went below last_size since the last block, the smallest size goes first (§4.2): the peer’s decoder must evict what this encoder evicted, or the two tables no longer hold the same entries. last_size follows, alone when nothing smaller was set. Returns the number of updates appended, 1 or 2 — the most a block may open with.

Source

pub fn reset_table(&mut self) -> usize

Empties the dynamic table and records the size updates that make the peer’s decoder empty its own: 0, then the current maximum size. RFC 7541 §4.2 provides exactly this: “This mechanism can be used to completely clear entries from the dynamic table by setting a maximum size of 0, which can subsequently be restored.” Returns that maximum size, which the caller signals through Self::encode_size_updates_into at the start of its next block.

The table changes when a block is ENCODED, not when it reaches the peer, so this is how a caller that dropped a block it encoded brings the two tables back together (sozu-proxy/sozu#1627). Entries are numbered from the newest (§2.3.3): every insertion the peer missed moves the older entries down one index in this table only, and a later block naming one of them makes the peer read another field, with no error. After the reset both tables are empty, whatever the peer missed, at the cost of the entries the next blocks would have reused.

Sound only when no block encoded before this call reaches the peer after the block that carries the updates: that later block would name entries of the table this empties.

Source

pub fn encode_header_into( &mut self, (name, value): (&[u8], &[u8]), out: &mut Vec<u8>, )

Appends the representation of one field to out.

Source

pub fn encode_into<'a, I>(&mut self, headers: I, out: &mut Vec<u8>)
where I: IntoIterator<Item = (&'a [u8], &'a [u8])>,

Appends the representation of every field to out, in order.

Source

pub fn encode_field( &mut self, name: &[u8], value: &[u8], representation: Representation, huffman: bool, out: &mut Vec<u8>, )

Appends one field in the requested representation, the strings Huffman coded when huffman.

Trait Implementations§

Source§

impl Debug for Encoder

Source§

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

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

impl Default for Encoder

Source§

fn default() -> Self

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

Auto Trait Implementations§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.