Browse the docs

silk.http.http2_frame.

HTTP/2 wire frame headers, error codes, and frame serialization from RFC 9113.

Use FrameHeader.read after collecting nine bytes. A connection must enforce its negotiated frame size and stream rules before it accepts the payload. Unknown frame types remain representable.

Import as FrameHeader with import silk.http.http2_frame { FrameHeader }.

Public declarations: 19.

preface#

silk
pub fn preface() -> &'static [u8]

Returns the client connection preface. The client sends SETTINGS immediately after these bytes.

NO_ERROR#

silk
pub const NO_ERROR: u32

Successful completion, wire error code 0.

PROTOCOL_ERROR#

silk
pub const PROTOCOL_ERROR: u32

A protocol rule violation, wire error code 1.

INTERNAL_ERROR#

silk
pub const INTERNAL_ERROR: u32

An implementation failure, wire error code 2.

FLOW_CONTROL_ERROR#

silk
pub const FLOW_CONTROL_ERROR: u32

A flow-control violation, wire error code 3.

SETTINGS_TIMEOUT#

silk
pub const SETTINGS_TIMEOUT: u32

A SETTINGS acknowledgment timeout, wire error code 4.

STREAM_CLOSED#

silk
pub const STREAM_CLOSED: u32

A frame on a closed stream, wire error code 5.

FRAME_SIZE_ERROR#

silk
pub const FRAME_SIZE_ERROR: u32

An invalid frame length, wire error code 6.

REFUSED_STREAM#

silk
pub const REFUSED_STREAM: u32

A request refused before processing, wire error code 7.

CANCEL#

silk
pub const CANCEL: u32

A cancelled stream, wire error code 8.

COMPRESSION_ERROR#

silk
pub const COMPRESSION_ERROR: u32

A malformed HPACK context, wire error code 9.

CONNECT_ERROR#

silk
pub const CONNECT_ERROR: u32

A failed CONNECT tunnel, wire error code 10.

ENHANCE_YOUR_CALM#

silk
pub const ENHANCE_YOUR_CALM: u32

A peer exceeded resource limits, wire error code 11.

INADEQUATE_SECURITY#

silk
pub const INADEQUATE_SECURITY: u32

The transport does not meet security requirements, wire error code 12.

HTTP_1_1_REQUIRED#

silk
pub const HTTP_1_1_REQUIRED: u32

The peer requires HTTP/1.1, wire error code 13.

ProtocolError#

silk
pub struct ProtocolError

An HTTP/2 error. Stream zero identifies a connection error; a nonzero identifier identifies a stream error.

Field code#

silk
pub code: u32

The wire error code for GOAWAY or RST_STREAM.

Field stream#

silk
pub stream: u32

Zero for a connection error, otherwise the affected stream identifier.

Implementation Copy for ProtocolError#

silk
impl Copy for ProtocolError

Implementation Debug for ProtocolError#

silk
impl Debug for ProtocolError

Operation debug#

silk
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut Writer

Writes the fields, as ProtocolError { code: ..., stream: ... }.

FrameHeader#

silk
pub struct FrameHeader

The nine-byte HTTP/2 frame header. The reserved stream bit is ignored when reading.

Field length#

silk
pub length: usize

Payload length, excluding the nine-byte header.

Field kind#

silk
pub kind: u8

The wire frame type, including extension types.

Field flags#

silk
pub flags: u8

Frame flags, including unknown flags that receivers ignore.

Field stream#

silk
pub stream: u32

The 31-bit stream identifier, or zero for a connection frame.

Implementation Copy for FrameHeader#

silk
impl Copy for FrameHeader

Implementation FrameHeader#

silk
impl FrameHeader

Associated function read#

silk
pub effect fn read(input: &[u8]) -> FrameHeader
    ! ProtocolError

Reads exactly nine header bytes. An incorrect input length fails with FRAME_SIZE_ERROR.

Method write#

silk
pub effect fn write(self: &Self, output: &mut Bytes, payload: &[u8]) -> ()
    ! ProtocolError | OutOfMemoryError
    ? &mut Allocator

Appends this header and payload. Invalid payload length or stream bits fail before output changes.

read32#

silk
pub fn read32(input: &[u8], offset: usize) -> u32

Reads four network-order bytes. The caller must supply four bytes starting at offset.

write32#

silk
pub effect fn write32(output: &mut Bytes, value: u32) -> ()
  ! OutOfMemoryError
  ? &mut Allocator

Appends four bytes in network order.

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.

View the source of this page