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][CBOR(v, t, p)]

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 CBOR body left untouched.

Constants§

MAX_FRAME_SIZE
Maximum allowed frame size (4 MiB).

Functions§

decode_message_frame
Decodes one complete length-prefixed frame from a borrowed byte slice.
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_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_from_buf
Tries to decode a complete message from a byte buffer.
try_decode_raw_from_buf
Tries to decode a complete raw frame from a byte buffer.
write_message
Writes a length-prefixed message to the given writer.
write_raw_frame
Writes a length-prefixed raw frame to the given writer.