Skip to main content

Module codec

Module codec 

Source
Expand description

Length-prefixed frame codec for reading and writing protocol messages.

Wire format: [len: u32 BE][id: u32 BE][flags: u8][body]. Control bodies are CBOR; generation-8 bulk bodies use a fixed raw header.

The correlation ID and flags sit in a fixed-position binary header so that relay intermediaries can route frames without CBOR parsing.

Structs§

RawFrame
A frame with the binary header parsed but the body left untouched.

Enums§

DecodedFrame
One fully validated control message or raw bulk record.

Constants§

MAX_FRAME_SIZE
Maximum allowed frame size (4 MiB).
MAX_WIRE_FRAME
Maximum complete encoded frame size, including the four-byte length prefix.

Functions§

decode_message_frame
Decodes one complete length-prefixed frame from a borrowed byte slice.
encode_bulk_header
Encodes the fixed outer and generation-8 bulk headers, leaving the payload separate.
encode_bulk_to_buf
Encodes a generation-8 raw bulk record into a contiguous byte buffer.
encode_raw_to_buf
Encodes a raw frame to a byte buffer using the length-prefixed format.
encode_to_buf
Encodes a message to a byte buffer using the length-prefixed frame format.
raw_frame_to_bulk
Decodes and validates a raw frame as a generation-8 bulk record.
raw_frame_to_message
Decodes a RawFrame into a typed Message by CBOR-deserializing the body.
read_message
Reads a length-prefixed message from the given reader.
read_raw_frame
Reads a length-prefixed raw frame from the given reader.
try_decode_frame_from_bytes
Decodes one complete control or generation-8 bulk frame from a cursor-based buffer.
try_decode_from_buf
Tries to decode a complete message from a byte buffer.
try_decode_from_bytes
Decode one complete typed frame from a cursor-based buffer without front-draining it.
try_decode_raw_from_buf
Tries to decode a complete raw frame from a byte buffer.
write_bulk_record
Writes a generation-8 raw bulk record without copying its payload.
write_message
Writes a length-prefixed message to the given writer.
write_raw_frame
Writes a length-prefixed raw frame to the given writer.