ntex_redis/cmd/
mod.rs

1//! Redis commands
2#![allow(non_snake_case, clippy::wrong_self_convention)]
3
4use super::codec::{Request, Response};
5use super::errors::CommandError;
6
7mod auth;
8mod connection;
9mod hashes;
10mod keys;
11mod lists;
12mod pubsub;
13mod strings;
14mod utils;
15
16pub use self::auth::Auth;
17pub use self::connection::{Ping, Reset, Select};
18pub use self::hashes::{HDel, HGet, HGetAll, HIncrBy, HLen, HSet};
19pub use self::keys::{Del, Exists, Expire, ExpireAt, Keys, Ttl, TtlResult};
20pub use self::lists::{LIndex, LPop, LPush, RPop, RPush};
21pub use self::pubsub::{
22    PSubscribe, PUnSubscribe, Publish, SPublish, SSubscribe, SUnSubscribe, Subscribe,
23    SubscribeItem, UnSubscribe,
24};
25pub use self::strings::{Get, IncrBy, Set};
26
27/// Trait implemented by types that can be used as redis commands
28pub trait Command {
29    /// Command output type
30    type Output;
31
32    /// Convert command to a redis request
33    fn to_request(self) -> Request;
34
35    /// Create command response from a redis response
36    fn to_output(val: Response) -> Result<Self::Output, CommandError>;
37}
38
39pub mod commands {
40    //! Command implementations
41    pub use super::auth::AuthCommand;
42    pub use super::hashes::{HDelCommand, HGetAllCommand, HSetCommand};
43    pub use super::keys::{KeysCommand, KeysPatternCommand, TtlCommand};
44    pub use super::lists::LPushCommand;
45    pub use super::pubsub::{PubSubCommand, SubscribeOutputCommand};
46    pub use super::strings::SetCommand;
47    pub use super::utils::{BulkOutputCommand, IntOutputCommand};
48}