Skip to main content

Module codec

Module codec 

Source
Available on crate feature h2 only.
Expand description

HTTP/2 frame codec (RFC 9113 Section 6).

Parses and writes the 9-octet frame header and every frame type: DATA, HEADERS, PRIORITY, RST_STREAM, SETTINGS, PUSH_PROMISE, PING, GOAWAY, WINDOW_UPDATE and CONTINUATION, including PADDED and PRIORITY flags. Validation covers frame-size limits, stream-id rules, settings values and field-block continuation discipline. Unknown frame types are ignored (RFC 9113 Section 4.1).

The decoder is incremental: feed it bytes with FrameDecoder::extend and call FrameDecoder::next_frame; it returns Ok(None) until a complete frame is buffered.

This module is the frame layer of the native HTTP/2 implementation (see CUSTOM_HTTP2_IMPL.md); stream and connection semantics (flow control, settings tracking, lifecycle) live in later steps on top of it.

Structs§

FrameDecoder
Incremental frame decoder over a growing buffer.
FrameWriter
Writes frames to an output buffer. The field-block writer (FrameWriter::write_field_block) splits the block across HEADERS/CONTINUATION frames at the peer’s frame-size limit.
Priority
Stream priority (RFC 9113 Section 6.3).
Setting
A SETTINGS parameter (RFC 9113 Section 6.5.2).

Enums§

Frame
A parsed frame. Payloads are zero-copy views over the decoder’s buffer (kept alive by Bytes refcounting until the frame is dropped); the connection layer reassembles field blocks from the block fragments and applies stream semantics. Padding, when present, is validated and stripped.

Constants§

CLIENT_PREFACE
The HTTP/2 connection preface (RFC 9113 Section 3.5).
DEFAULT_INITIAL_WINDOW_SIZE
The initial connection flow-control window (RFC 9113 Section 5.2.1).
DEFAULT_MAX_FRAME_SIZE
The initial maximum frame payload size (RFC 9113 Section 4.2).
FRAME_HEADER_LEN
Length of the fixed frame header (RFC 9113 Section 4.1).
MAX_FRAME_SIZE_LIMIT
The largest settable frame payload size (2^24-1).
MAX_WINDOW_SIZE
The largest legal flow-control window (2^31-1).