pub fn decode_frame_with_consumed(
buf: &[u8],
max_frame_bytes: usize,
) -> Result<(Frame, usize), CodecError>Expand description
Decode one complete length-prefixed frame from buf and report the
number of bytes consumed: LENGTH_PREFIX_BYTES plus the declared
payload length. Bytes beyond the consumed prefix — if any — belong to
the next frame, letting a transport split a buffered stream into frames
without re-parsing the length prefix itself. decode_frame is this
function with the consumed count discarded.
max_frame_bytes is PAYLOAD-ONLY, as in decode_frame.
Decode errors are connection-terminal. An error from this function
carries NO consumed count: once a frame fails to decode, this crate
cannot say where the failed frame ends, so the stream position is
unrecoverable. A transport must map the error through
CodecError::wire_code, send the corresponding wire error, and close
the connection — never attempt to resynchronize and keep reading.