Skip to main content

Encoder

Struct Encoder 

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

QPACK encoder: dynamic table owner and field section encoder.

Implementations§

Source§

impl Encoder

Source

pub fn new(max_capacity: u64, huffman: bool) -> Self

Creates an encoder bound to a decoder that advertised the given max_capacity in SETTINGS_QPACK_MAX_TABLE_CAPACITY.

Source

pub fn max_capacity(&self) -> u64

The maximum dynamic table capacity permitted by the decoder.

Source

pub fn encode_section( &mut self, stream_id: u64, headers: &[(Bytes, Bytes)], ) -> EncodedSection

Encodes headers for the field section on stream_id into an encoded field section plus the encoder stream instructions the decoder needs to process it.

The dynamic table is used only when the decoder allows a capacity of at least one entry (RFC 9204 Section 3.2.3): a maximum capacity below 32 bytes cannot hold any entry and disables the dynamic table.

Source

pub fn set_capacity(&mut self, capacity: u64) -> Option<Bytes>

Sets the dynamic table capacity (4.3.1), evicting as needed. Returns the instruction, or None when the capacity is unchanged, exceeds the decoder’s maximum, or the reduction would evict entries the decoder still needs (RFC 9204 Section 2.1.1).

Source

pub fn feed_decoder_stream(&mut self, buf: &[u8]) -> Result<(), QpackError>

Processes the decoder stream instructions in buf. Section Acknowledgments (4.4.1) free a field section’s references, Stream Cancellations (4.4.2) free every reference of a cancelled stream, and Insert Count Increments (4.4.3) raise the Known Received Count.

Only an Insert Count Increment (4.4.3) is a connection error: a zero increment, or one that advances past the number of inserts sent (RFC 9204 Section 2.1.4). A Section Acknowledgment or Stream Cancellation that matches no outstanding field section is benign — RFC 9204 Section 4.4 defines no error for it and a peer may send one for a section already acknowledged or cancelled — so it is ignored rather than closing the connection.

Trait Implementations§

Source§

impl Debug for Encoder

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