[][src]Struct deadpool_redis::Cmd

pub struct Cmd { /* fields omitted */ }

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>[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 Clone + ExactSizeIterator + Iterator<Item = Arg<&[u8]>>
[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.

impl DerefMut for Cmd[src]

impl From<Cmd> for Cmd[src]

impl Into<Cmd> for Cmd[src]

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]

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

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

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

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

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.

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.