Skip to main content

decode_frame

Function decode_frame 

Source
pub fn decode_frame<T>(buf: &[u8]) -> Result<Option<(T, usize)>, Error>
where T: for<'de> Deserialize<'de>,
Expand description

Decode one frame from a byte slice.

Returns Ok(None) if the buffer does not yet contain a complete frame (the caller should read more bytes and retry). Returns Err(InvalidData) if the declared length exceeds MAX_BODY_SIZE — this prevents a malicious client from forcing the server to allocate gigabytes for a body that will never arrive.