pub fn decode_frame_raw(
buf: &[u8],
max: usize,
) -> Result<Option<(&[u8], usize)>, DecodeError>Expand description
Decode one frame’s body, borrowed from buf, plus the total bytes
consumed (4 + body).
This is the framing layer on its own: the prefix read, the cap check
(WIRE-020/021, before any slicing) and the body slice — with no assumption
about what the body is. A product whose frames carry its own envelope
rather than Thunder’s Request/Response reuses the framing through this
instead of reimplementing it, which is the whole point of a shared wire
crate. It is the Rust counterpart of the TypeScript package’s
FrameReader.
Returns Ok(None) when the buffer does not yet hold a complete frame
(read more and retry — WIRE-022).
A zero-length frame is not an error here: it comes back as an empty body slice, which is what lets a raw consumer skip a keep-alive (WIRE-024).
decode_frame_with_limit is this function plus a MessagePack decode, so
there is exactly one implementation of the framing rules.