Skip to main content

ParseProgress

Enum ParseProgress 

Source
pub enum ParseProgress<'a> {
    Incomplete,
    NeedValue {
        header: SetHeader<'a>,
        value_len: usize,
        value_prefix: &'a [u8],
        header_consumed: usize,
    },
    ValueTooLarge {
        value_len: usize,
        value_prefix_len: usize,
        header_consumed: usize,
        max_value_size: usize,
    },
    Complete(Command<'a>, usize),
}
Expand description

Result of incremental parsing.

Variants§

§

Incomplete

Need more data to continue parsing.

§

NeedValue

Command header parsed, waiting for value data.

The caller should:

  1. Allocate a buffer for the value (e.g., in cache segment)
  2. Copy value_prefix to the start of that buffer
  3. Receive remaining value_len - value_prefix.len() bytes into the buffer
  4. Call complete_with_value() to finish parsing

Fields

§header: SetHeader<'a>

Parsed command header with metadata.

§value_len: usize

Total size of the value in bytes.

§value_prefix: &'a [u8]

Bytes of value already in the parse buffer (may be empty). These must be copied to the target buffer before receiving more.

§header_consumed: usize

Bytes consumed from buffer so far (header only).

§

ValueTooLarge

Value exceeds maximum allowed size - needs to be drained.

The caller should:

  1. Send an error response to the client
  2. Drain value_len + 2 bytes (value + trailing CRLF) from the connection
  3. Resume normal parsing

Fields

§value_len: usize

Total size of the value in bytes.

§value_prefix_len: usize

Bytes of value already in the parse buffer (to be discarded).

§header_consumed: usize

Bytes consumed from buffer so far (header only).

§max_value_size: usize

Maximum allowed value size.

§

Complete(Command<'a>, usize)

Fully parsed command (used for non-SET commands or small values).

Trait Implementations§

Source§

impl<'a> Debug for ParseProgress<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ParseProgress<'a>

§

impl<'a> RefUnwindSafe for ParseProgress<'a>

§

impl<'a> Send for ParseProgress<'a>

§

impl<'a> Sync for ParseProgress<'a>

§

impl<'a> Unpin for ParseProgress<'a>

§

impl<'a> UnsafeUnpin for ParseProgress<'a>

§

impl<'a> UnwindSafe for ParseProgress<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.