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
impl RedisCoreConnection
Sourcepub fn connect(
addr: &SocketAddr,
) -> impl Future<Item = Self, Error = RedisError>
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.
Sourcepub fn send(self, req: RedisCommand) -> Send
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§
impl Freeze for RedisCoreConnection
impl !RefUnwindSafe for RedisCoreConnection
impl Send for RedisCoreConnection
impl !Sync for RedisCoreConnection
impl Unpin for RedisCoreConnection
impl UnsafeUnpin for RedisCoreConnection
impl !UnwindSafe for RedisCoreConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more