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
MAX_FRAME_BYTEScaps an arbitrary frame at 16 MiB. Larger frames cause the broker to disconnect.MAX_HELLO_BYTEScaps the initial Hello envelope at 64 KiB. Larger Hello frames cause the broker to returnRefusedand close. Hello-specific reads should passMAX_HELLO_BYTEStoread_frame_with_cap.
§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§
- Framing
Error - Errors produced by
read_frame/write_frame.
Constants§
- ENVELOPE_
VERSION - Framing byte for v1. Alias of
crate::broker::FRAMING_VERSION_V1to 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
readerwith the default 16 MiB cap. - read_
frame_ with_ cap - Read one v1 frame from
reader, rejecting bodies larger thanmax_bytes. - write_
frame - Write one v1 frame to
writer.