QuicHttp3.Qpack (elixir_quic_http3 v1.0.0)

Copy Markdown View Source

Pure QPACK (RFC 9204) wire primitives and decoder-side dynamic table.

decode_header_block/2 is the static/literal profile: dynamic references are rejected. decode_field_section/3 decodes against a bounded dynamic table, including Required Insert Count/Base, relative and post-base references, and reports sections whose Required Insert Count is not yet satisfied as blocked. apply_encoder_instructions/3 applies peer encoder-stream instructions incrementally with a bounded partial-instruction buffer. The local encoder remains static/literal.

Summary

Types

A field section waiting for its Required Insert Count.

t()

Functions

Look up a live dynamic entry by absolute index.

Apply complete encoder-stream instructions and return the unconsumed suffix.

Decode complete decoder-stream instructions and return the partial suffix.

Decode a complete field section against the decoder's dynamic table.

Decode the Required Insert Count and Base prefix (RFC 9204 Section 4.5.1).

Encode a Required Insert Count for a decoder advertising max_capacity.

Insert Count Increment decoder instruction; the increment must be positive.

Insert an entry as instructed by the peer encoder, evicting oldest entries.

Decoder MaxEntries derived from the advertised maximum capacity.

Build a dynamic table.

Retry a blocked section; it stays blocked until enough inserts arrive.

Section Acknowledgment decoder instruction.

Encoded bytes retained by a blocked section.

Required Insert Count of a blocked section.

Set Dynamic Table Capacity; above the advertised maximum is an error.

Stream Cancellation decoder instruction.

Types

decode_result()

@type decode_result() :: {:ok, non_neg_integer(), binary()} | :more | {:error, term()}

decoder_instruction()

@type decoder_instruction() ::
  {:section_ack, non_neg_integer()}
  | {:stream_cancel, non_neg_integer()}
  | {:insert_count_increment, non_neg_integer()}

dynamic_entry()

@type dynamic_entry() :: %{name: binary(), value: binary(), size: pos_integer()}

field()

@type field() :: {binary(), binary()}

section()

@opaque section()

A field section waiting for its Required Insert Count.

t()

@type t() :: %QuicHttp3.Qpack{
  capacity: non_neg_integer(),
  entries: [dynamic_entry()],
  insert_count: non_neg_integer(),
  max_capacity: non_neg_integer(),
  size: non_neg_integer()
}

Functions

absolute(arg1, index)

@spec absolute(t(), integer()) ::
  {:ok, field()} | {:error, :invalid_dynamic_reference}

Look up a live dynamic entry by absolute index.

apply_encoder_instructions(table, data, opts \\ [])

@spec apply_encoder_instructions(t(), binary(), keyword()) ::
  {:ok, t(), binary()} | {:error, term()}

Apply complete encoder-stream instructions and return the unconsumed suffix.

A trailing partial instruction is returned for buffering; it is bounded by :max_buffer (default 4 * max_capacity + 64).

decode_decoder_instructions(data)

@spec decode_decoder_instructions(binary()) ::
  {:ok, [decoder_instruction()], binary()} | {:error, term()}

Decode complete decoder-stream instructions and return the partial suffix.

decode_field_section(data, table, opts \\ [])

@spec decode_field_section(binary(), t(), keyword()) ::
  {:ok, [field()], non_neg_integer()}
  | {:blocked, section()}
  | :more
  | {:error, term()}

Decode a complete field section against the decoder's dynamic table.

Returns {:ok, fields, required_insert_count}, or {:blocked, section} when the Required Insert Count exceeds the table's insert count. Resume a blocked section with resume_field_section/3 after more inserts arrive.

decode_header_block(data, opts \\ [])

@spec decode_header_block(binary(), keyword()) ::
  {:ok, [field()]} | :more | {:error, term()}

decode_integer(arg1, prefix_bits)

@spec decode_integer(binary(), 1..8) :: decode_result()

decode_section_prefix(data, table)

@spec decode_section_prefix(binary(), t()) ::
  {:ok, non_neg_integer(), non_neg_integer(), binary()}
  | :more
  | {:error, term()}

Decode the Required Insert Count and Base prefix (RFC 9204 Section 4.5.1).

decode_string(data)

@spec decode_string(binary()) :: {:ok, binary(), binary()} | :more | {:error, term()}

dynamic(arg1, index)

@spec dynamic(t(), non_neg_integer()) ::
  {:ok, field()} | {:error, :invalid_dynamic_index}

encode_header_block(fields, opts \\ [])

@spec encode_header_block([field()], keyword()) :: {:ok, binary()} | {:error, term()}

encode_integer(value, prefix_bits, prefix)

@spec encode_integer(non_neg_integer(), 1..8, non_neg_integer()) ::
  {:ok, binary()} | {:error, term()}

encode_required_insert_count(required, max_capacity)

@spec encode_required_insert_count(non_neg_integer(), non_neg_integer()) ::
  non_neg_integer()

Encode a Required Insert Count for a decoder advertising max_capacity.

encode_string(value)

@spec encode_string(binary()) :: {:ok, binary()} | {:error, term()}

encode_string(value, list)

insert(table, name, value)

@spec insert(t(), binary(), binary()) :: {:ok, t()} | {:error, term()}

insert_count_increment(increment)

@spec insert_count_increment(pos_integer()) :: nonempty_binary()

Insert Count Increment decoder instruction; the increment must be positive.

insert_entry(table, name, value)

@spec insert_entry(t(), binary(), binary()) :: {:ok, t()} | {:error, term()}

Insert an entry as instructed by the peer encoder, evicting oldest entries.

max_entries(qpack)

@spec max_entries(t()) :: non_neg_integer()

Decoder MaxEntries derived from the advertised maximum capacity.

new(opts \\ [])

@spec new(keyword()) :: t()

Build a dynamic table.

:capacity is the current capacity. :max_capacity is the locally advertised SETTINGS_QPACK_MAX_TABLE_CAPACITY; it defaults to :capacity. A decoder table starts with new(max_capacity: advertised) at capacity zero.

resume_field_section(section, table, opts)

@spec resume_field_section(section(), t(), keyword()) ::
  {:ok, [field()], non_neg_integer()}
  | {:blocked, section()}
  | :more
  | {:error, term()}

Retry a blocked section; it stays blocked until enough inserts arrive.

section_ack(stream_id)

@spec section_ack(non_neg_integer()) :: nonempty_binary()

Section Acknowledgment decoder instruction.

section_bytes(arg)

@spec section_bytes(section()) :: non_neg_integer()

Encoded bytes retained by a blocked section.

section_required_insert_count(arg)

@spec section_required_insert_count(section()) :: pos_integer()

Required Insert Count of a blocked section.

set_capacity(table, capacity)

@spec set_capacity(t(), non_neg_integer()) :: {:ok, t()} | {:error, term()}

Set Dynamic Table Capacity; above the advertised maximum is an error.

static(index)

@spec static(non_neg_integer()) :: {:ok, field()} | {:error, :invalid_static_index}

stream_cancel(stream_id)

@spec stream_cancel(non_neg_integer()) :: nonempty_binary()

Stream Cancellation decoder instruction.