Skip to main content

Command

Enum Command 

Source
pub enum Command<'a> {
Show 14 variants Get { key: &'a [u8], }, Gets { keys: Vec<&'a [u8]>, }, Set { key: &'a [u8], flags: u32, exptime: u32, data: &'a [u8], }, Add { key: &'a [u8], flags: u32, exptime: u32, data: &'a [u8], }, Replace { key: &'a [u8], flags: u32, exptime: u32, data: &'a [u8], }, Cas { key: &'a [u8], flags: u32, exptime: u32, data: &'a [u8], cas_unique: u64, }, Delete { key: &'a [u8], }, FlushAll, Version, Quit, Incr { key: &'a [u8], delta: u64, noreply: bool, }, Decr { key: &'a [u8], delta: u64, noreply: bool, }, Append { key: &'a [u8], data: &'a [u8], noreply: bool, }, Prepend { key: &'a [u8], data: &'a [u8], noreply: bool, },
}
Expand description

A parsed Memcache command with references to the original buffer.

Commands are parsed with zero-copy semantics where possible.

Variants§

§

Get

GET command

Fields

§key: &'a [u8]
§

Gets

Multi-GET command

Fields

§keys: Vec<&'a [u8]>
§

Set

SET command

Fields

§key: &'a [u8]
§flags: u32
§exptime: u32
§data: &'a [u8]
§

Add

ADD command - store only if key doesn’t exist

Fields

§key: &'a [u8]
§flags: u32
§exptime: u32
§data: &'a [u8]
§

Replace

REPLACE command - store only if key exists

Fields

§key: &'a [u8]
§flags: u32
§exptime: u32
§data: &'a [u8]
§

Cas

CAS (compare-and-swap) command

Fields

§key: &'a [u8]
§flags: u32
§exptime: u32
§data: &'a [u8]
§cas_unique: u64
§

Delete

DELETE command

Fields

§key: &'a [u8]
§

FlushAll

FLUSH_ALL command

§

Version

VERSION command

§

Quit

QUIT command

§

Incr

INCR command - increment numeric value

Fields

§key: &'a [u8]
§delta: u64
§noreply: bool
§

Decr

DECR command - decrement numeric value

Fields

§key: &'a [u8]
§delta: u64
§noreply: bool
§

Append

APPEND command - append data to existing value

Fields

§key: &'a [u8]
§data: &'a [u8]
§noreply: bool
§

Prepend

PREPEND command - prepend data to existing value

Fields

§key: &'a [u8]
§data: &'a [u8]
§noreply: bool

Implementations§

Source§

impl<'a> Command<'a>

Source

pub fn parse(buffer: &'a [u8]) -> Result<(Self, usize), ParseError>

Parse a command from a byte buffer using default options.

Returns the parsed command and the number of bytes consumed.

§Zero-copy

The returned command contains references to the input buffer for keys and data, avoiding allocation in the hot path.

Source

pub fn parse_with_options( buffer: &'a [u8], options: &ParseOptions, ) -> Result<(Self, usize), ParseError>

Parse a command from a byte buffer with custom options.

This allows configuring DoS protection limits like maximum key size, value size, and line length.

Source

pub fn name(&self) -> &'static str

Returns the command name as a string.

Source

pub fn is_quit(&self) -> bool

Returns true if this command should close the connection.

Trait Implementations§

Source§

impl<'a> Clone for Command<'a>

Source§

fn clone(&self) -> Command<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Command<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Command<'a>

Source§

fn eq(&self, other: &Command<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for Command<'a>

Source§

impl<'a> StructuralPartialEq for Command<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Command<'a>

§

impl<'a> RefUnwindSafe for Command<'a>

§

impl<'a> Send for Command<'a>

§

impl<'a> Sync for Command<'a>

§

impl<'a> Unpin for Command<'a>

§

impl<'a> UnsafeUnpin for Command<'a>

§

impl<'a> UnwindSafe for Command<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.