Expand description
Zero-copy RESP3 parser.
Operates on buffered byte slices. The caller is responsible for reading data from the network into a buffer — this parser is purely synchronous.
The parser uses a Cursor<&[u8]> to track its position through the
input buffer without consuming it, allowing the caller to retry once
more data arrives.
§Single-pass design
Earlier versions used a two-pass approach: check() to validate a
complete frame exists, then parse() to build Frame values. This
scanned every byte twice. The current implementation does a single
pass that builds Frame values directly, returning Incomplete if
the buffer doesn’t contain enough data yet.
§Zero-copy bulk strings
When parsing from a Bytes buffer via parse_frame_bytes, bulk
string data is returned as a zero-copy Bytes::slice() into the
original buffer. This avoids a heap allocation per bulk string.
The fallback parse_frame copies bulk data for callers that
only have a &[u8].
Functions§
- parse_
frame - Checks whether
bufcontains a complete RESP3 frame and parses it. - parse_
frame_ bytes - Zero-copy frame parser. Bulk string data is returned as
Bytes::slice()into the input buffer, avoiding a heap copy per bulk string.