Skip to main content

parse_command_borrowed

Function parse_command_borrowed 

Source
pub fn parse_command_borrowed(
    buf: &[u8],
) -> Result<Option<(ArgvBorrowed<'_>, usize)>, ProtocolError>
Expand description

Parse one command from the front of buf, recording each arg as a (start, end) range into buf rather than copying its bytes.

The returned ArgvBorrowed is a zero-copy view: get(i) slices directly into buf. Use this on the local single-shard hot path; call ArgvBorrowed::into_owned before storing an argv past the buffer’s lifetime (cross-shard dispatch, MULTI queue, AOF logging).

Return shape matches crate::parse_command: Ok(Some((argv, consumed))), Ok(None) if more bytes are needed, Err on malformed input.