pub struct Encoder {
table: Table,
max_allowed_size: usize,
size_update: Option<SizeUpdate>,
scratch: BytesMut,
}Fields§
§table: Table§max_allowed_size: usize§size_update: Option<SizeUpdate>§scratch: BytesMutReusable buffer for the encoded header block of a single frame.
A header block only has to live until it is copied into the
connection write buffer, so the buffer that holds it can be reused
across frames instead of being allocated and freed per frame. See
take_scratch / return_scratch.
Implementations§
Source§impl Encoder
impl Encoder
pub fn new(max_size: usize, capacity: usize) -> Encoder
Sourcepub(crate) fn take_scratch(&mut self) -> BytesMut
pub(crate) fn take_scratch(&mut self) -> BytesMut
Takes the reusable buffer for one header-block encode.
The buffer is returned by return_scratch once the encoded block has
been copied into the write buffer. If it is not returned - the
CONTINUATION path keeps it, since the remainder is still needed - the
next call simply starts from a fresh buffer.
Sourcepub(crate) fn return_scratch(&mut self, scratch: BytesMut)
pub(crate) fn return_scratch(&mut self, scratch: BytesMut)
Returns a fully-written header block buffer for reuse.
Sourcepub fn update_max_size(&mut self, val: usize)
pub fn update_max_size(&mut self, val: usize)
Queues a max size update.
The next call to encode will include a dynamic size update frame.
Sourcepub fn encode<I>(&mut self, headers: I, dst: &mut BytesMut)
pub fn encode<I>(&mut self, headers: I, dst: &mut BytesMut)
Encode a set of headers into the provide buffer