Skip to main content

Module framing

Module framing 

Source
Expand description

v1 broker wire framing — [u8 framing_version][u32 LE body_length][prost body].

§Frozen-forever

This module implements THE truly-frozen-forever invariant of v1 per #228 “Frozen-forever commitments”: the framing byte is 1, the body length is a little-endian u32, and the body is a prost payload. Any future protocol version is signalled by changing the framing byte, which lets a v1 broker recognize a v2 client and return Refused{ERROR_VERSION_UNSUPPORTED} instead of decoding garbage.

§Sizes

§Sync, not async

Phase 1 ships a synchronous std::io::{Read, Write} implementation because the client cargo feature does not pull in tokio. The broker server (Phase 4) runs under feature = "daemon" (which does include tokio) and can wrap a TcpStream/NamedPipeServer either through tokio::io::sync_bridge or by re-implementing the wire layout on AsyncRead/AsyncWrite. The wire format is the same; only the surface API differs.

Enums§

FramingError
Errors produced by read_frame/write_frame.

Constants§

ENVELOPE_VERSION
Framing byte for v1. Alias of crate::broker::FRAMING_VERSION_V1 to match the name used in the #228/#230 specs verbatim.
MAX_FRAME_BYTES
Default per-frame size cap (16 MiB). Alias of crate::broker::MAX_FRAME_SIZE_BYTES.
MAX_HELLO_BYTES
Hello-envelope size cap (64 KiB). Alias of crate::broker::MAX_HELLO_SIZE_BYTES.

Functions§

read_frame
Read one v1 frame from reader with the default 16 MiB cap.
read_frame_with_cap
Read one v1 frame from reader, rejecting bodies larger than max_bytes.
write_frame
Write one v1 frame to writer.