silk.http.hpack.
HTTP/2 field compression as defined by RFC 7541.
Keep one Decoder for received fields and one Encoder for sent fields. Each field block uses
the table left by the previous block. Field names and values are wire bytes, without UTF-8 conversion.
Decoding accepts every representation, including Huffman strings. Encoding uses indexed fields
and literal strings, with dynamic indexing only when the field is not sensitive.
Import as Decoder with import silk.http.hpack { Decoder }.
Public declarations: 5.
Field#
pub struct Field<'a>One borrowed field for compression. Names and values contain the exact wire bytes.
Field name#
pub name: &'a [u8]The field name, including a leading colon for a pseudo-header.
Field value#
pub value: &'a [u8]The field value.
Field sensitive#
pub sensitive: boolIf true, encoders use the never-indexed representation.
Implementation Copy for Field<'a>#
impl<'a> Copy for Field<'a>Header#
pub struct HeaderOne decoded field. Dropping it releases its name and value storage.
Field name#
pub name: BytesThe field name bytes.
Field value#
pub value: BytesThe field value bytes.
Field sensitive#
pub sensitive: boolTrue if the sender used the never-indexed representation.
Implementation Header#
impl HeaderMethod view#
pub fn view(self: &Self) -> FieldBorrows the field bytes. The view cannot outlive the owned field.
HpackError#
pub struct HpackErrorA malformed field block or a configured resource limit.
Field offset#
pub offset: usizeThe byte offset at which decoding failed.
Field limit#
pub limit: boolTrue for a resource limit, false for invalid compression syntax.
Implementation Debug for HpackError#
impl Debug for HpackErrorOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the fields, as HpackError { offset: ..., limit: ... }.
Decoder#
pub struct DecoderA connection's HPACK decoder with a bounded dynamic table and decoded field list.
Implementation Decoder#
impl DecoderAssociated function make#
pub fn make(tableBytes: usize, maxFields: usize, maxBytes: usize) -> DecoderCreates a decoder with the negotiated table limit and per-block field count and byte limits. The byte limit counts name bytes, value bytes, and 32 bytes for each field.
Method setMaximum#
pub fn setMaximum(self: &mut Self, maximum: usize) -> ()Applies an acknowledged SETTINGS_HEADER_TABLE_SIZE. A reduction requires the next block to update its table.
Method decode#
pub effect fn decode(self: &mut Self, input: &[u8]) -> List<Header>
! HpackError | OutOfMemoryError
? &mut AllocatorDecodes one complete field block and updates the dynamic table. A failure invalidates the compression context; close its HTTP/2 connection.
Encoder#
pub struct EncoderA connection's HPACK encoder. Sensitive fields are never indexed.
Implementation Encoder#
impl EncoderAssociated function make#
pub fn make(tableBytes: usize) -> EncoderCreates an encoder with the peer's current table limit.
Method setMaximum#
pub fn setMaximum(self: &mut Self, maximum: usize) -> ()Applies the peer's table limit and emits the required updates at the next field block.
Method encode#
pub effect fn encode(self: &mut Self, fields: &[Field]) -> Bytes
! OutOfMemoryError
? &mut AllocatorEncodes a complete field block. The next block must use this same encoder.
Category: HTTP.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.