Skip to main content

decode_frame_with_limit

Function decode_frame_with_limit 

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

Decode one frame, rejecting bodies larger than max before the body is even inspected (WIRE-020/021).

A zero-length frame yields DecodeError::KeepAlive: it is a valid frame (WIRE-024) but carries no body to deserialize. Use decode_frame_raw to consume it as an empty body instead.