Expand description
Versioned network message envelope (spec section 4.10, S1D-001).
Every message on every MongrelDB wire protocol travels inside a
ProtocolEnvelope, never as an unversioned payload. The canonical
encoding is:
protocol_version : u32 LE
message_type : u32 LE
payload_len : u32 LE
payload : [u8; payload_len]
payload_crc32 : u32 LEThe CRC-32 (IEEE, reflected) covers the protocol version, the message
type, the payload length, and the payload. This mirrors the fail-closed
shape of mongreldb-log’s CommandEnvelope: unknown protocol versions,
oversized payloads, truncated frames, trailing bytes, and checksum
mismatches are all decode errors (spec section 4.10: unknown required
fields or incompatible versions fail closed).
Unlike CommandEnvelope the checksum is a CRC-32 rather than SHA-256:
this crate’s dependency set is frozen (serde, thiserror,
mongreldb-types), and transport integrity plus peer authentication are
provided by TLS 1.3 (S1D-002), so the checksum’s job here is only
framing sanity, not cryptographic authentication.
Encoding is deterministic: ProtocolEnvelope::encode is a pure
function of the envelope fields, so equal envelopes produce
byte-identical frames and decode(encode(e)) is the identity.
Payload evolution rules (spec section 4.10):
message_typediscriminants and payload field numbers are never reused; new message types are allocated fresh numbers.- The envelope never interprets payload bytes; payload decoding is the adapter’s job (Protobuf control frames, Arrow IPC result frames, per S1D-002 and ADR 0005).
- Unknown protocol versions fail closed with
EnvelopeError::UnsupportedVersion.
Structs§
- Protocol
Envelope - The versioned, checksummed form of every protocol message.
Enums§
- Envelope
Error - Errors produced while verifying or decoding a
ProtocolEnvelope.
Constants§
- CHECKSUM_
LEN - Encoded length of the trailing checksum.
- HEADER_
LEN - Encoded length of the fixed header preceding the payload.
- MAX_
MESSAGE_ PAYLOAD_ BYTES - Upper bound on a single message payload.
- MIN_
SUPPORTED_ PROTOCOL_ VERSION - The oldest protocol version this build accepts.
- PROTOCOL_
VERSION - The protocol version this build writes.