Function decode_frames
pub fn decode_frames<T: DeserializeOwned>(
buffer: Vec<u8>,
max_frame_len: u32,
) -> Result<DecodedFrames<T>, FramingError>Expand description
Decode every complete frame in buffer, consuming it.
Frames whose body does not deserialize into T (an unknown message kind
or a corrupt body) are skipped and counted rather than aborting the batch,
since the length prefix delimits each body exactly.
§Arguments
buffer- Bytes read from the control channel, possibly ending in a partial frame. Its allocation is reused for the returned remainder.max_frame_len- Largest body, in bytes, to accept (this endpoint’s receive ceiling).
§Returns
A DecodedFrames holding the decoded messages, the count of skipped
frames, and any unconsumed trailing bytes.
§Errors
Returns FramingError::FrameTooLarge if a frame’s declared length
exceeds max_frame_len, which leaves the stream unresynchronizable.