Skip to main content

read_frame

Function read_frame 

Source
pub fn read_frame<R: Read, T: for<'de> Deserialize<'de>>(
    r: &mut R,
) -> Result<Framed<T>>
Expand description

Read one length-prefixed CBOR frame, distinguishing an undecodable payload from an unreadable stream.

Caps the frame at MAX_FRAME_BYTES so a malformed prefix can’t trigger an unbounded allocation. An oversized prefix stays a hard io::Error rather than an Framed::Undecodable, because those bytes were never counted off the stream — the connection really is desynchronised at that point.

§Errors

io::Error for anything that leaves the stream unusable: EOF, a short read, a transport failure, or an oversized length prefix.