1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Redis integration for Actix framework.
//!
//! ## Documentation
//! * [API Documentation (Development)](http://actix.github.io/actix-redis/actix_redis/)
//! * [API Documentation (Releases)](https://docs.rs/actix-redis/)
//! * [Chat on gitter](https://gitter.im/actix/actix)
//! * Cargo package: [actix-redis](https://crates.io/crates/actix-redis)
//! * Minimum supported Rust version: 1.21 or later
//!
extern crate actix;
extern crate backoff;
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
#[macro_use]
extern crate log;
#[macro_use]
extern crate redis_async;
#[macro_use]
extern crate failure;

mod redis;
pub use redis::{Command, RedisActor};

#[cfg(feature = "web")]
extern crate actix_web;
#[cfg(feature = "web")]
extern crate cookie;
#[cfg(feature = "web")]
extern crate http;
#[cfg(feature = "web")]
extern crate rand;
#[cfg(feature = "web")]
extern crate serde;
#[cfg(feature = "web")]
extern crate serde_json;

#[cfg(feature = "web")]
mod session;
#[cfg(feature = "web")]
pub use session::RedisSessionBackend;

/// General purpose actix redis error
#[derive(Fail, Debug)]
pub enum Error {
    #[fail(display = "Redis error {}", _0)]
    Redis(redis_async::error::Error),
    /// Receiving message during reconnecting
    #[fail(display = "Redis: Not connected")]
    NotConnected,
    /// Cancel all waters when connection get dropped
    #[fail(display = "Redis: Disconnected")]
    Disconnected,
}

unsafe impl Send for Error {}
unsafe impl Sync for Error {}

impl From<redis_async::error::Error> for Error {
    fn from(err: redis_async::error::Error) -> Error {
        Error::Redis(err)
    }
}

// re-export
pub use redis_async::error::Error as RespError;
pub use redis_async::resp::RespValue;