Struct deadpool_redis::Cmd[][src]

pub struct Cmd { /* fields omitted */ }
Expand description

Wrapper for redis::Cmd which makes it compatible with the query_async method which takes a ConnectionLike as argument.

This Implementation could be simplified a lot via RFC 2393.

See redis::Cmd

Implementations

impl Cmd[src]

pub fn new() -> Self[src]

pub fn arg<T: ToRedisArgs>(&mut self, arg: T) -> &mut Cmd[src]

pub fn cursor_arg(&mut self, cursor: u64) -> &mut Cmd[src]

pub async fn query_async<T: FromRedisValue + Send>(
    &self,
    conn: &mut ConnectionWrapper
) -> RedisResult<T>
[src]

pub async fn execute_async(
    &self,
    con: &mut ConnectionWrapper
) -> RedisResult<()>
[src]

Methods from Deref<Target = Cmd>

pub fn arg<T>(&mut self, arg: T) -> &mut Cmd where
    T: ToRedisArgs
[src]

Appends an argument to the command. The argument passed must be a type that implements ToRedisArgs. Most primitive types as well as vectors of primitive types implement it.

For instance all of the following are valid:

redis::cmd("SET").arg(&["my_key", "my_value"]);
redis::cmd("SET").arg("my_key").arg(42);
redis::cmd("SET").arg("my_key").arg(b"my_value");

pub fn cursor_arg(&mut self, cursor: u64) -> &mut Cmd[src]

Works similar to arg but adds a cursor argument. This is always an integer and also flips the command implementation to support a different mode for the iterators where the iterator will ask for another batch of items when the local data is exhausted.

let mut cmd = redis::cmd("SSCAN");
let mut iter : redis::Iter<isize> =
    cmd.arg("my_set").cursor_arg(0).clone().iter(&mut con).unwrap();
for x in iter {
    // do something with the item
}

pub fn get_packed_command(&self) -> Vec<u8, Global>[src]

Returns the packed command as a byte vector.

pub fn in_scan_mode(&self) -> bool[src]

Returns true if the command is in scan mode.

pub fn query<T>(&self, con: &mut dyn ConnectionLike) -> Result<T, RedisError> where
    T: FromRedisValue
[src]

Sends the command as query to the connection and converts the result to the target redis value. This is the general way how you can retrieve data.

pub async fn query_async<C, T>(
    &'_ self,
    con: &'_ mut C
) -> Result<T, RedisError> where
    C: ConnectionLike,
    T: FromRedisValue
[src]

Async version of query.

pub fn execute(&self, con: &mut dyn ConnectionLike)[src]

This is a shortcut to query() that does not return a value and will fail the task if the query fails because of an error. This is mainly useful in examples and for simple commands like setting keys.

This is equivalent to a call of query like this:

let _ : () = redis::cmd("PING").query(&mut con).unwrap();

pub fn args_iter(
    &self
) -> impl Iterator<Item = Arg<&[u8]>> + Clone + ExactSizeIterator
[src]

Returns an iterator over the arguments in this command (including the command name itself)

Trait Implementations

impl Deref for Cmd[src]

type Target = Cmd

The resulting type after dereferencing.

fn deref(&self) -> &Cmd[src]

Dereferences the value.

impl DerefMut for Cmd[src]

fn deref_mut(&mut self) -> &mut Cmd[src]

Mutably dereferences the value.

impl From<Cmd> for Cmd[src]

fn from(cmd: Cmd) -> Self[src]

Performs the conversion.

impl Into<Cmd> for Cmd[src]

fn into(self) -> Cmd[src]

Performs the conversion.

Auto Trait Implementations

impl RefUnwindSafe for Cmd

impl Send for Cmd

impl Sync for Cmd

impl Unpin for Cmd

impl UnwindSafe for Cmd

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.