pub fn decode_frame(
buf: &[u8],
max_frame: usize,
) -> Result<Option<(ObsEnvelope, usize)>, Error>Expand description
Decode one length-prefixed envelope from buf.
Returns Ok(None) when the buffer is too short to contain a full
length + payload; otherwise returns the decoded envelope and the
number of bytes consumed. Caller is responsible for draining
consumed bytes.
max_frame bounds the declared length — anything larger is treated
as a framing error (a well-behaved emitter never produces envelopes
that big; crossing the limit usually means the stream is
desynchronised).
§Errors
Returns io::ErrorKind::InvalidData when the declared length
exceeds max_frame or when buffa decoding fails.