Skip to main content

Command

Enum Command 

Source
pub enum Command<'a> {
Show 48 variants Ping, Get { key: &'a [u8], }, Set { key: &'a [u8], value: &'a [u8], ex: Option<u64>, px: Option<u64>, nx: bool, xx: bool, }, Del { key: &'a [u8], }, MGet { keys: Vec<&'a [u8]>, }, Config { subcommand: &'a [u8], args: Vec<&'a [u8]>, }, Cluster { subcommand: &'a [u8], args: Vec<&'a [u8]>, }, Asking, ReadOnly, ReadWrite, FlushDb, FlushAll, Incr { key: &'a [u8], }, Decr { key: &'a [u8], }, IncrBy { key: &'a [u8], delta: i64, }, DecrBy { key: &'a [u8], delta: i64, }, Append { key: &'a [u8], value: &'a [u8], }, HSet { key: &'a [u8], fields: Vec<(&'a [u8], &'a [u8])>, }, HGet { key: &'a [u8], field: &'a [u8], }, HMGet { key: &'a [u8], fields: Vec<&'a [u8]>, }, HGetAll { key: &'a [u8], }, HDel { key: &'a [u8], fields: Vec<&'a [u8]>, }, HExists { key: &'a [u8], field: &'a [u8], }, HLen { key: &'a [u8], }, HKeys { key: &'a [u8], }, HVals { key: &'a [u8], }, HSetNx { key: &'a [u8], field: &'a [u8], value: &'a [u8], }, HIncrBy { key: &'a [u8], field: &'a [u8], delta: i64, }, LPush { key: &'a [u8], values: Vec<&'a [u8]>, }, RPush { key: &'a [u8], values: Vec<&'a [u8]>, }, LPop { key: &'a [u8], count: Option<usize>, }, RPop { key: &'a [u8], count: Option<usize>, }, LRange { key: &'a [u8], start: i64, stop: i64, }, LLen { key: &'a [u8], }, LIndex { key: &'a [u8], index: i64, }, LSet { key: &'a [u8], index: i64, value: &'a [u8], }, LTrim { key: &'a [u8], start: i64, stop: i64, }, LPushX { key: &'a [u8], values: Vec<&'a [u8]>, }, RPushX { key: &'a [u8], values: Vec<&'a [u8]>, }, SAdd { key: &'a [u8], members: Vec<&'a [u8]>, }, SRem { key: &'a [u8], members: Vec<&'a [u8]>, }, SMembers { key: &'a [u8], }, SIsMember { key: &'a [u8], member: &'a [u8], }, SMisMember { key: &'a [u8], members: Vec<&'a [u8]>, }, SCard { key: &'a [u8], }, SPop { key: &'a [u8], count: Option<usize>, }, SRandMember { key: &'a [u8], count: Option<i64>, }, Type { key: &'a [u8], },
}
Expand description

A parsed Redis command with references to the original buffer.

Commands are parsed with zero-copy semantics - the key and value fields reference slices of the original input buffer.

Variants§

§

Ping

PING command

§

Get

GET key

Fields

§key: &'a [u8]
§

Set

SET key value [EX seconds] [PX milliseconds] [NX|XX]

Fields

§key: &'a [u8]
§value: &'a [u8]
§nx: bool
§xx: bool
§

Del

DEL key

Fields

§key: &'a [u8]
§

MGet

MGET key [key …]

Fields

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

Config

CONFIG subcommand [args…]

Fields

§subcommand: &'a [u8]
§args: Vec<&'a [u8]>
§

Cluster

CLUSTER subcommand [args…]

Fields

§subcommand: &'a [u8]
§args: Vec<&'a [u8]>
§

Asking

ASKING — used before retrying a command after an ASK redirect

§

ReadOnly

READONLY — enable read queries on a replica node

§

ReadWrite

READWRITE — disable READONLY mode

§

FlushDb

FLUSHDB

§

FlushAll

FLUSHALL

§

Incr

INCR key - Increment the integer value of a key by one

Fields

§key: &'a [u8]
§

Decr

DECR key - Decrement the integer value of a key by one

Fields

§key: &'a [u8]
§

IncrBy

INCRBY key delta - Increment the integer value of a key by delta

Fields

§key: &'a [u8]
§delta: i64
§

DecrBy

DECRBY key delta - Decrement the integer value of a key by delta

Fields

§key: &'a [u8]
§delta: i64
§

Append

APPEND key value - Append a value to a key

Fields

§key: &'a [u8]
§value: &'a [u8]
§

HSet

HSET key field value [field value …] - Set field(s) in a hash

Fields

§key: &'a [u8]
§fields: Vec<(&'a [u8], &'a [u8])>
§

HGet

HGET key field - Get a field from a hash

Fields

§key: &'a [u8]
§field: &'a [u8]
§

HMGet

HMGET key field [field …] - Get multiple fields from a hash

Fields

§key: &'a [u8]
§fields: Vec<&'a [u8]>
§

HGetAll

HGETALL key - Get all fields and values from a hash

Fields

§key: &'a [u8]
§

HDel

HDEL key field [field …] - Delete field(s) from a hash

Fields

§key: &'a [u8]
§fields: Vec<&'a [u8]>
§

HExists

HEXISTS key field - Check if field exists in a hash

Fields

§key: &'a [u8]
§field: &'a [u8]
§

HLen

HLEN key - Get the number of fields in a hash

Fields

§key: &'a [u8]
§

HKeys

HKEYS key - Get all field names in a hash

Fields

§key: &'a [u8]
§

HVals

HVALS key - Get all values in a hash

Fields

§key: &'a [u8]
§

HSetNx

HSETNX key field value - Set field only if it doesn’t exist

Fields

§key: &'a [u8]
§field: &'a [u8]
§value: &'a [u8]
§

HIncrBy

HINCRBY key field increment - Increment hash field by integer

Fields

§key: &'a [u8]
§field: &'a [u8]
§delta: i64
§

LPush

LPUSH key element [element …] - Push to left of list

Fields

§key: &'a [u8]
§values: Vec<&'a [u8]>
§

RPush

RPUSH key element [element …] - Push to right of list

Fields

§key: &'a [u8]
§values: Vec<&'a [u8]>
§

LPop

LPOP key [count] - Pop from left of list

Fields

§key: &'a [u8]
§count: Option<usize>
§

RPop

RPOP key [count] - Pop from right of list

Fields

§key: &'a [u8]
§count: Option<usize>
§

LRange

LRANGE key start stop - Get range of elements

Fields

§key: &'a [u8]
§start: i64
§stop: i64
§

LLen

LLEN key - Get list length

Fields

§key: &'a [u8]
§

LIndex

LINDEX key index - Get element by index

Fields

§key: &'a [u8]
§index: i64
§

LSet

LSET key index element - Set element by index

Fields

§key: &'a [u8]
§index: i64
§value: &'a [u8]
§

LTrim

LTRIM key start stop - Trim list to range

Fields

§key: &'a [u8]
§start: i64
§stop: i64
§

LPushX

LPUSHX key element [element …] - Push to left only if list exists

Fields

§key: &'a [u8]
§values: Vec<&'a [u8]>
§

RPushX

RPUSHX key element [element …] - Push to right only if list exists

Fields

§key: &'a [u8]
§values: Vec<&'a [u8]>
§

SAdd

SADD key member [member …] - Add members to set

Fields

§key: &'a [u8]
§members: Vec<&'a [u8]>
§

SRem

SREM key member [member …] - Remove members from set

Fields

§key: &'a [u8]
§members: Vec<&'a [u8]>
§

SMembers

SMEMBERS key - Get all members of set

Fields

§key: &'a [u8]
§

SIsMember

SISMEMBER key member - Check if member exists in set

Fields

§key: &'a [u8]
§member: &'a [u8]
§

SMisMember

SMISMEMBER key member [member …] - Check multiple members

Fields

§key: &'a [u8]
§members: Vec<&'a [u8]>
§

SCard

SCARD key - Get set cardinality

Fields

§key: &'a [u8]
§

SPop

SPOP key [count] - Remove and return random member(s)

Fields

§key: &'a [u8]
§count: Option<usize>
§

SRandMember

SRANDMEMBER key [count] - Get random member(s) without removal

Fields

§key: &'a [u8]
§count: Option<i64>
§

Type

TYPE key - Get the type of key

Fields

§key: &'a [u8]

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 limits.

Returns the parsed command and the number of bytes consumed.

§Zero-copy

The returned command contains references to the input buffer, so the buffer must outlive the command. This avoids allocation for keys and values.

§Errors

Returns ParseError::Incomplete if more data is needed. Returns other errors for malformed or unknown commands.

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 is useful for setting custom limits on bulk string size to prevent denial-of-service attacks or to enforce server-side value size limits.

§Zero-copy

The returned command contains references to the input buffer, so the buffer must outlive the command. This avoids allocation for keys and values.

§Errors

Returns ParseError::Incomplete if more data is needed. Returns ParseError::BulkStringTooLong if a bulk string exceeds the limit. Returns other errors for malformed or unknown commands.

Source

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

Returns the command name as a string.

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.