Skip to main content

Decoder

Struct Decoder 

Source
pub struct Decoder { /* private fields */ }
Available on crate feature h3 only.
Expand description

QPACK decoder: dynamic table mirror and field section decoder.

Implementations§

Source§

impl Decoder

Source

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.

Source

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).

Source

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).

Source

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).

Source

pub fn pending_blocked(&self) -> usize

The number of field sections currently buffered as blocked.

Source

pub fn take_decoder_stream(&mut self) -> Bytes

Takes the accumulated decoder stream instructions.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Decoder

Source§

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

Formats the value using the given formatter. 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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more