Skip to main content

parse_streaming

Function parse_streaming 

Source
pub fn parse_streaming<'a>(
    buffer: &'a [u8],
    options: &ParseOptions,
    streaming_threshold: usize,
) -> Result<ParseProgress<'a>, ParseError>
Expand description

Parse a command, potentially yielding early for large SET values.

This function provides the streaming parse capability. For SET commands with values >= STREAMING_THRESHOLD, it returns NeedValue after parsing the header, allowing the caller to receive the value directly into a target buffer.

For all other commands (including small SETs), it behaves identically to Command::parse().

§Arguments

  • buffer - The input buffer containing RESP data
  • options - Parse options (max lengths, etc.)
  • streaming_threshold - Minimum value size for streaming (use STREAMING_THRESHOLD)

§Returns

  • Ok(ParseProgress::Incomplete) - Need more data
  • Ok(ParseProgress::NeedValue { .. }) - SET header parsed, value pending
  • Ok(ParseProgress::Complete(cmd, consumed)) - Fully parsed command
  • Err(ParseError) - Parse error