pub struct Encoder { /* private fields */ }Expand description
The connection-level HPACK encoder of one direction.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn set_max_table_size(&mut self, max_size: usize)
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.
Sourcepub fn change_max_table_size(&mut self, max_size: usize)
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.
Sourcepub fn encode_size_updates_into(
&mut self,
last_size: usize,
out: &mut Vec<u8>,
) -> usize
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.
Sourcepub fn reset_table(&mut self) -> usize
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.
Sourcepub fn encode_header_into(
&mut self,
(name, value): (&[u8], &[u8]),
out: &mut Vec<u8>,
)
pub fn encode_header_into( &mut self, (name, value): (&[u8], &[u8]), out: &mut Vec<u8>, )
Appends the representation of one field to out.
Sourcepub fn encode_into<'a, I>(&mut self, headers: I, out: &mut Vec<u8>)
pub fn encode_into<'a, I>(&mut self, headers: I, out: &mut Vec<u8>)
Appends the representation of every field to out, in order.
Sourcepub fn encode_field(
&mut self,
name: &[u8],
value: &[u8],
representation: Representation,
huffman: bool,
out: &mut Vec<u8>,
)
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.