Module codec
Expand description
Length-prefixed CBOR framing for the v1 control channel.
Each frame on the wire is:
[u32 length, big-endian] [CBOR body of length bytes]The length counts only the CBOR body, not the 4-byte prefix. The maximum
body size is a per-call parameter, not part of the wire format, so peers
enforce a negotiated limit (default
crate::v1::limits::DEFAULT_MAX_FRAME_LEN).
Forward compatibility rides on the length prefix. #[serde(other)] absorbs
an unknown unit variant, but cannot fold an unknown data-carrying
message into a unit catch-all; for those, decode_frames drops the whole
(length-delimited) frame and counts the skip, so an unknown message never
crashes the stream. A length prefix over the enforced limit is the one
unrecoverable case: the boundary can no longer be trusted, so decoding fails
hard and the caller tears the connection down.
Structs§
- Decoded
Frames - Result of decoding a buffer that may hold several frames.
- Limited
Writer 🔒 - A
Writesink that buffers at mostlimitbytes.
Enums§
- Framing
Error - Error produced while encoding or decoding length-prefixed CBOR frames.
Constants§
- LENGTH_
PREFIX_ 🔒LEN - Number of bytes in a frame’s big-endian
u32length prefix.
Functions§
- decode_
frames - Decode every complete frame in
buffer, consuming it. - encode_
frame - Encode a message into a single length-prefixed CBOR frame.