pub struct Decoder { /* private fields */ }h3 only.Expand description
QPACK decoder: dynamic table mirror and field section decoder.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn new(max_capacity: u64, max_blocked_streams: usize) -> Self
pub fn new(max_capacity: u64, max_blocked_streams: usize) -> Self
Creates a decoder that advertised max_capacity in
SETTINGS_QPACK_MAX_TABLE_CAPACITY and max_blocked_streams in
SETTINGS_QPACK_BLOCKED_STREAMS.
Sourcepub fn set_max_field_section_size(&mut self, size: usize)
pub fn set_max_field_section_size(&mut self, size: usize)
Sets the maximum size of a decoded field section: the locally
advertised SETTINGS_MAX_FIELD_SECTION_SIZE (RFC 9114 Section
7.2.4.1). The budget is per stream and accumulates across its field
sections (request headers and trailers); a section that pushes a
stream’s cumulative name and value octets over this is rejected
with QPACK_DECOMPRESSION_FAILED (RFC 9204 Section 4.5).
Sourcepub fn inserted(&self) -> u64
pub fn inserted(&self) -> u64
The total number of insertions and duplications materialized from the encoder stream so far; the decoder’s Insert Count (RFC 9204 Section 2.1.1).
Sourcepub fn known_received(&self) -> u64
pub fn known_received(&self) -> u64
The Known Received Count: insertions and duplications the decoder has acknowledged or incremented (RFC 9204 Section 2.1.4).
Sourcepub fn pending_blocked(&self) -> usize
pub fn pending_blocked(&self) -> usize
The number of field sections currently buffered as blocked.
Sourcepub fn take_decoder_stream(&mut self) -> Bytes
pub fn take_decoder_stream(&mut self) -> Bytes
Takes the accumulated decoder stream instructions.
Sourcepub fn feed_decoder_stream(&mut self, buf: &[u8]) -> Result<(), QpackError>
pub fn feed_decoder_stream(&mut self, buf: &[u8]) -> Result<(), QpackError>
Parses the peer’s QPACK decoder stream instructions (RFC 9204 Section 4.4): Section Acknowledgments, Stream Cancellations, and Insert Count Increments.
An Insert Count Increment with a zero value is a decoder stream error (Section 4.4.3); any malformed instruction is too. The instructions are not otherwise acted upon: this decoder emits its own decoder-stream instructions and never tracks the peer’s acknowledgements, so it only needs to validate what the peer sends.
Sourcepub fn feed_encoder_stream(
&mut self,
buf: &[u8],
) -> Result<Vec<UnblockedSection>, QpackError>
pub fn feed_encoder_stream( &mut self, buf: &[u8], ) -> Result<Vec<UnblockedSection>, QpackError>
Processes the encoder stream instructions in buf, materializing
dynamic table updates.
Returns the field sections that were blocked and can now be decoded, in arrival order. The Section Acknowledgment for each is queued in the decoder stream, together with a coalesced Insert Count Increment when the table grew beyond the acknowledged count.
Sourcepub fn decode_block(
&mut self,
buf: &[u8],
stream_id: u64,
now: u64,
) -> Result<Option<Vec<(Bytes, Bytes)>>, QpackError>
pub fn decode_block( &mut self, buf: &[u8], stream_id: u64, now: u64, ) -> Result<Option<Vec<(Bytes, Bytes)>>, QpackError>
Decodes an encoded field section received on stream_id.
Returns the decoded header list, or None when the section was
buffered as blocked (it is returned by a later
Decoder::feed_encoder_stream call).
now is the caller’s monotonic clock (any unit); it is recorded for
Decoder::expire_blocked. Sections that cannot be processed in
order are never decoded early: a section on a stream with buffered
blocked sections joins the queue even when it could be decoded
already (RFC 9204 Section 2.2.1 requires in-order processing).
Sourcepub fn stream_finished(&mut self, stream_id: u64)
pub fn stream_finished(&mut self, stream_id: u64)
Notifies that stream_id finished receiving (the peer closed its
send side): no further field sections can arrive on it, so its
field-section size budget is released. Safe to call when the stream
never carried a field section.
Must only be called when no field section of the stream remains
buffered as blocked: a buffered section is decoded later by
Decoder::feed_encoder_stream, which would then restart the
stream’s budget from scratch. The HTTP/3 layer calls this only upon
observing the peer’s stream end, which implies every section of the
stream (headers, trailers) has decoded.
Sourcepub fn stream_cancelled(&mut self, stream_id: u64) -> Bytes
pub fn stream_cancelled(&mut self, stream_id: u64) -> Bytes
Notifies that stream_id was reset or abandoned: buffered blocked
sections for it are dropped and a Stream Cancellation instruction is
queued (RFC 9204 Section 2.2.2.2). Returns the instruction.
Sourcepub fn expire_blocked(&mut self, now: u64, max_age: u64) -> Bytes
pub fn expire_blocked(&mut self, now: u64, max_age: u64) -> Bytes
Drops blocked sections older than max_age in the caller’s clock
units, queueing one Stream Cancellation per affected stream. Returns
the instructions.