Skip to main content

Encoder

Struct Encoder 

Source
pub struct Encoder {
    pub huffman: bool,
    pub indexing: bool,
    /* private fields */
}
Expand description

A stateful header block encoder.

Exact static or dynamic matches are sent as indexed fields; other fields are literals with incremental indexing, except sensitive fields (never indexed), fields whose values rarely repeat, and fields larger than half the table (without indexing). Strings are Huffman coded when that is shorter.

Fields§

§huffman: bool

Use Huffman coding when it is shorter (default true).

§indexing: bool

Add literals to the dynamic table (default true).

Implementations§

Source§

impl Encoder

Source

pub fn new(limit: usize) -> Self

An encoder that keeps at most limit bytes of dynamic table. The peer’s table starts at 4096 (the protocol default); a smaller limit is announced in the first block.

Source

pub fn set_peer_max_table_size(&mut self, peer: usize)

Applies the peer’s SETTINGS_HEADER_TABLE_SIZE. The encoder uses the smaller of that and its own limit, and announces the change at the start of the next block.

Source

pub fn table_size(&self) -> usize

Current dynamic table size in octets.

Source

pub fn table_len(&self) -> usize

Number of dynamic table entries.

Source

pub fn begin_block(&mut self, out: &mut Vec<u8>)

Starts a header block: emits any pending dynamic table size updates (RFC 7541 §4.2).

Source

pub fn encode(&mut self, fields: &[(&[u8], &[u8])], out: &mut Vec<u8>)

Encodes a whole header block.

Source

pub fn field(&mut self, name: &[u8], value: &[u8], out: &mut Vec<u8>)

Encodes one field of the current block (after Encoder::begin_block).

Trait Implementations§

Source§

impl Clone for Encoder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Encoder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Encoder

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.