Struct RedisCoreConnection

Source
pub struct RedisCoreConnection { /* private fields */ }
Expand description

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);

Implementations§

Source§

impl RedisCoreConnection

Source

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

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

Source

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

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

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