Expand description
Length-prefixed framing for the binary (CBOR) protocol.
Port of the upstream packages/protocol/ module.
4-byte big-endian unsigned payload length followed by the payload bytes.
FrameDecoder incrementally splits arbitrary byte chunks into complete
payloads and enforces a maximum frame length so a corrupt/hostile stream
cannot make the peer allocate unbounded memory.
Structs§
- Frame
Decoder - Incremental decoder: feed byte chunks, get whole payloads back.
- Frame
Error - Framing error.
Constants§
- DEFAULT_
MAX_ FRAME_ LENGTH - Native
DEFAULT_MAX_FRAME_LENGTH(16 MiB). - FRAME_
HEADER_ LENGTH - Native
FRAME_HEADER_LENGTH. - PAYLOAD_
BLOCK_ SIZE - Native
PAYLOAD_BLOCK_SIZE.
Functions§
- assert_
complete_ frame - Validate that
framecontains exactly one complete frame withinmax. - encode_
frame - Prefix
payloadwith its 4-byte big-endian length.