2020-04-21 22:39:31 +02:00
|
|
|
mod connection;
|
2020-04-13 22:03:06 +02:00
|
|
|
mod manager;
|
2020-04-21 22:39:31 +02:00
|
|
|
mod msg;
|
2020-04-13 22:03:06 +02:00
|
|
|
|
2020-04-21 20:38:32 +02:00
|
|
|
pub(self) use super::{Event, EventErr};
|
2020-04-18 03:56:31 +02:00
|
|
|
pub(self) use connection::RedisConn;
|
2020-04-20 00:02:24 +02:00
|
|
|
pub use manager::Error;
|
2020-04-21 22:39:31 +02:00
|
|
|
pub use manager::Manager;
|
2020-04-13 22:03:06 +02:00
|
|
|
|
2020-04-18 03:56:31 +02:00
|
|
|
use connection::RedisConnErr;
|
|
|
|
use msg::RedisParseErr;
|
|
|
|
|
|
|
|
enum RedisCmd {
|
2020-04-13 22:03:06 +02:00
|
|
|
Subscribe,
|
|
|
|
Unsubscribe,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RedisCmd {
|
2020-04-18 03:56:31 +02:00
|
|
|
fn into_sendable(self, tl: &str) -> (Vec<u8>, Vec<u8>) {
|
2020-04-13 22:03:06 +02:00
|
|
|
match self {
|
|
|
|
RedisCmd::Subscribe => (
|
2020-04-15 02:37:49 +02:00
|
|
|
[
|
|
|
|
b"*2\r\n$9\r\nsubscribe\r\n$",
|
|
|
|
tl.len().to_string().as_bytes(),
|
|
|
|
b"\r\n",
|
|
|
|
tl.as_bytes(),
|
|
|
|
b"\r\n",
|
|
|
|
]
|
|
|
|
.concat(),
|
|
|
|
[
|
|
|
|
b"*3\r\n$3\r\nSET\r\n$",
|
|
|
|
tl.len().to_string().as_bytes(),
|
|
|
|
b"\r\n",
|
|
|
|
tl.as_bytes(),
|
|
|
|
b"\r\n$1\r\n1\r\n",
|
|
|
|
]
|
|
|
|
.concat(),
|
2020-04-13 22:03:06 +02:00
|
|
|
),
|
|
|
|
RedisCmd::Unsubscribe => (
|
2020-04-15 02:37:49 +02:00
|
|
|
[
|
|
|
|
b"*2\r\n$11\r\nunsubscribe\r\n$",
|
|
|
|
tl.len().to_string().as_bytes(),
|
|
|
|
b"\r\n",
|
|
|
|
tl.as_bytes(),
|
|
|
|
b"\r\n",
|
|
|
|
]
|
|
|
|
.concat(),
|
|
|
|
[
|
|
|
|
b"*3\r\n$3\r\nSET\r\n$",
|
|
|
|
tl.len().to_string().as_bytes(),
|
|
|
|
b"\r\n",
|
|
|
|
tl.as_bytes(),
|
|
|
|
b"\r\n$1\r\n0\r\n",
|
|
|
|
]
|
|
|
|
.concat(),
|
2020-04-13 22:03:06 +02:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|