redis_driver/resp/
command.rs1use crate::resp::{CommandArgs, IntoArgs};
2
3#[must_use]
5#[inline(always)]
6pub fn cmd(name: &'static str) -> Command {
7 Command::new(name)
8}
9
10#[derive(Debug, Clone)]
11pub struct Command {
12 pub name: &'static str,
13 pub args: CommandArgs,
14}
15
16impl Command {
17 #[must_use]
18 #[inline(always)]
19 pub fn new(name: &'static str) -> Self {
20 Self {
21 name,
22 args: CommandArgs::default(),
23 }
24 }
25
26 #[must_use]
27 #[inline(always)]
28 pub fn arg<A>(self, arg: A) -> Self
29 where
30 A: IntoArgs,
31 {
32 Self {
33 name: self.name,
34 args: self.args.arg(arg),
35 }
36 }
37
38 #[must_use]
39 #[inline(always)]
40 pub fn arg_if<A>(self, condition: bool, arg: A) -> Self
41 where
42 A: IntoArgs,
43 {
44 Self {
45 name: self.name,
46 args: self.args.arg_if(condition, arg),
47 }
48 }
49}