Skip to main content

Command

Enum Command 

Source
pub enum Command {
Show 50 variants Ping(Option<Bytes>), Echo(Bytes), Get { key: String, }, Set { key: String, value: Bytes, expire: Option<SetExpire>, nx: bool, xx: bool, }, Incr { key: String, }, Decr { key: String, }, Del { keys: Vec<String>, }, Exists { keys: Vec<String>, }, MGet { keys: Vec<String>, }, MSet { pairs: Vec<(String, Bytes)>, }, Expire { key: String, seconds: u64, }, Ttl { key: String, }, Persist { key: String, }, Pttl { key: String, }, Pexpire { key: String, milliseconds: u64, }, DbSize, Info { section: Option<String>, }, BgSave, BgRewriteAof, FlushDb, Scan { cursor: u64, pattern: Option<String>, count: Option<usize>, }, LPush { key: String, values: Vec<Bytes>, }, RPush { key: String, values: Vec<Bytes>, }, LPop { key: String, }, RPop { key: String, }, LRange { key: String, start: i64, stop: i64, }, LLen { key: String, }, Type { key: String, }, ZAdd { key: String, flags: ZAddFlags, members: Vec<(f64, String)>, }, ZRem { key: String, members: Vec<String>, }, ZScore { key: String, member: String, }, ZRank { key: String, member: String, }, ZCard { key: String, }, ZRange { key: String, start: i64, stop: i64, with_scores: bool, }, HSet { key: String, fields: Vec<(String, Bytes)>, }, HGet { key: String, field: String, }, HGetAll { key: String, }, HDel { key: String, fields: Vec<String>, }, HExists { key: String, field: String, }, HLen { key: String, }, HIncrBy { key: String, field: String, delta: i64, }, HKeys { key: String, }, HVals { key: String, }, HMGet { key: String, fields: Vec<String>, }, SAdd { key: String, members: Vec<String>, }, SRem { key: String, members: Vec<String>, }, SMembers { key: String, }, SIsMember { key: String, member: String, }, SCard { key: String, }, Unknown(String),
}
Expand description

A parsed client command, ready for execution.

Variants§

§

Ping(Option<Bytes>)

PING with an optional message. Returns PONG or echoes the message.

§

Echo(Bytes)

ECHO . Returns the message back to the client.

§

Get

GET . Returns the value or nil.

Fields

§

Set

SET [EX seconds | PX milliseconds] [NX | XX].

Fields

§value: Bytes
§nx: bool

Only set the key if it does not already exist.

§xx: bool

Only set the key if it already exists.

§

Incr

INCR . Increments the integer value of a key by 1.

Fields

§

Decr

DECR . Decrements the integer value of a key by 1.

Fields

§

Del

DEL [key …]. Returns the number of keys removed.

Fields

§keys: Vec<String>
§

Exists

EXISTS [key …]. Returns the number of keys that exist.

Fields

§keys: Vec<String>
§

MGet

MGET [key …]. Returns the values for all specified keys.

Fields

§keys: Vec<String>
§

MSet

MSET [key value …]. Sets multiple key-value pairs.

Fields

§pairs: Vec<(String, Bytes)>
§

Expire

EXPIRE . Sets a TTL on an existing key.

Fields

§seconds: u64
§

Ttl

TTL . Returns remaining time-to-live in seconds.

Fields

§

Persist

PERSIST . Removes the expiration from a key.

Fields

§

Pttl

PTTL . Returns remaining time-to-live in milliseconds.

Fields

§

Pexpire

PEXPIRE . Sets a TTL in milliseconds on an existing key.

Fields

§milliseconds: u64
§

DbSize

DBSIZE. Returns the number of keys in the database.

§

Info

INFO [section]. Returns server info. Currently only supports “keyspace”.

Fields

§section: Option<String>
§

BgSave

BGSAVE. Triggers a background snapshot.

§

BgRewriteAof

BGREWRITEAOF. Triggers an AOF rewrite (snapshot + truncate).

§

FlushDb

FLUSHDB. Removes all keys from the database.

§

Scan

SCAN [MATCH pattern] [COUNT count]. Iterates keys.

Fields

§cursor: u64
§pattern: Option<String>
§count: Option<usize>
§

LPush

LPUSH [value …]. Pushes values to the head of a list.

Fields

§values: Vec<Bytes>
§

RPush

RPUSH [value …]. Pushes values to the tail of a list.

Fields

§values: Vec<Bytes>
§

LPop

LPOP . Pops a value from the head of a list.

Fields

§

RPop

RPOP . Pops a value from the tail of a list.

Fields

§

LRange

LRANGE . Returns a range of elements by index.

Fields

§start: i64
§stop: i64
§

LLen

LLEN . Returns the length of a list.

Fields

§

Type

TYPE . Returns the type of the value stored at key.

Fields

§

ZAdd

ZADD [NX|XX] [GT|LT] [CH] [score member …].

Fields

§members: Vec<(f64, String)>
§

ZRem

ZREM [member …]. Removes members from a sorted set.

Fields

§members: Vec<String>
§

ZScore

ZSCORE . Returns the score of a member.

Fields

§member: String
§

ZRank

ZRANK . Returns the rank of a member (0-based).

Fields

§member: String
§

ZCard

ZCARD . Returns the cardinality (number of members) of a sorted set.

Fields

§

ZRange

ZRANGE [WITHSCORES]. Returns a range by rank.

Fields

§start: i64
§stop: i64
§with_scores: bool
§

HSet

HSET [field value …]. Sets field-value pairs in a hash.

Fields

§fields: Vec<(String, Bytes)>
§

HGet

HGET . Gets a field’s value from a hash.

Fields

§field: String
§

HGetAll

HGETALL . Gets all field-value pairs from a hash.

Fields

§

HDel

HDEL [field …]. Deletes fields from a hash.

Fields

§fields: Vec<String>
§

HExists

HEXISTS . Checks if a field exists in a hash.

Fields

§field: String
§

HLen

HLEN . Returns the number of fields in a hash.

Fields

§

HIncrBy

HINCRBY . Increments a hash field’s integer value.

Fields

§field: String
§delta: i64
§

HKeys

HKEYS . Returns all field names in a hash.

Fields

§

HVals

HVALS . Returns all values in a hash.

Fields

§

HMGet

HMGET [field …]. Gets multiple field values from a hash.

Fields

§fields: Vec<String>
§

SAdd

SADD [member …]. Adds members to a set.

Fields

§members: Vec<String>
§

SRem

SREM [member …]. Removes members from a set.

Fields

§members: Vec<String>
§

SMembers

SMEMBERS . Returns all members of a set.

Fields

§

SIsMember

SISMEMBER . Checks if a member exists in a set.

Fields

§member: String
§

SCard

SCARD . Returns the cardinality (number of members) of a set.

Fields

§

Unknown(String)

A command we don’t recognize (yet).

Implementations§

Source§

impl Command

Source

pub fn from_frame(frame: Frame) -> Result<Command, ProtocolError>

Parses a Frame into a Command.

Expects an array frame where the first element is the command name (as a bulk or simple string) and the rest are arguments.

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

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 Debug for Command

Source§

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

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

impl PartialEq for Command

Source§

fn eq(&self, other: &Command) -> 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 StructuralPartialEq for Command

Auto Trait Implementations§

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.