Skip to main content

parse_frame_bytes

Function parse_frame_bytes 

Source
pub fn parse_frame_bytes(
    buf: &Bytes,
) -> Result<Option<(Frame, usize)>, ProtocolError>
Expand description

Zero-copy frame parser. Bulk string data is returned as Bytes::slice() into the input buffer, avoiding a heap copy per bulk string.

Use this on the hot path when the caller has a Bytes (e.g. from BytesMut::freeze()).

Returns Ok(Some((frame, consumed))) if a complete frame was parsed, Ok(None) if the buffer doesn’t contain enough data yet, or Err(...) if the data is malformed.