Skip to main content

Module framing

Module framing 

Source
Expand description

Bounded length-delimited framing for streaming structured-text payloads.

A frame is a 4-byte big-endian unsigned length prefix followed by exactly that many payload bytes. Every read is bounded by an explicit maximum so a malformed or hostile peer can never make a reader allocate without limit. Use this to carry one Codec-encoded value per frame over any blocking Read/Write transport (a pipe, a socket, a subprocess’s stdio).

write_value / read_value encode and decode typed values through an injected codec; write_frame / read_frame move raw payload bytes when the caller owns serialization.

Constants§

DEFAULT_MAX_FRAME_BYTES
Default maximum accepted payload size for a single frame (16 MiB).

Functions§

decode_value
Decode an already-read frame payload into T through codec.
read_frame
Read one length-delimited frame, bounded by max_bytes.
read_value
Read one frame and decode it into T through codec.
write_frame
Write one length-delimited frame carrying payload, flushing on completion.
write_value
Encode value with codec and write it as one length-delimited frame.