[][src]Struct redis_asio::RedisCoreConnection

pub struct RedisCoreConnection { /* fields omitted */ }

Actual Redis connection converts packets from RESP packets into RedisValue and from RedisCommand into RESP packets.

Example

use std::net::SocketAddr;
use futures::Future;
use redis_asio::{RedisCoreConnection, RedisValue, command, from_redis_value};

let address = &"127.0.0.1:6379".parse::<SocketAddr>().unwrap();

let set_req = command("SET").arg("foo").arg(123);
let get_req = command("GET").arg("foo");

let future = RedisCoreConnection::connect(address)
    .and_then(move |con| con.send(set_req))
    .and_then(|(con, response)| {
        assert_eq!(RedisValue::Ok, response, "Expect Ok");
        con.send(get_req)
    })
    .map(move |(_, response)|
        assert_eq!(123, from_redis_value(&response).unwrap()))
    .map_err(|_| unreachable!());
 tokio::run(future);

Methods

impl RedisCoreConnection[src]

pub fn connect(
    addr: &SocketAddr
) -> impl Future<Item = Self, Error = RedisError>
[src]

Open a connection to Redis server and wrap it into RedisCoreConnection, that will be available in the future.

pub fn send(self, req: RedisCommand) -> Send[src]

Send request as a RedisCommand and return Send represents the future Future<Item=(RedisCoreConnection, RedisValue), Error=RedisError>

Auto Trait Implementations

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.