serde_resp/macros.rs
1//! Here are all the macros for convenience. Refer to [RESPType](crate::RESPType) for usage examples.
2
3/// `simple!(...)` is equivalent to `RESP::SimpleString(...)`.
4#[macro_export]
5macro_rules! simple {
6 ($x:expr) => {
7 RESP::SimpleString($x)
8 };
9}
10
11/// `err_str!(...)` is equivalent to `RESP::Error(...)`.
12#[macro_export]
13macro_rules! err_str {
14 ($x:expr) => {
15 RESP::Error($x)
16 };
17}
18
19/// `int!(...)` is equivalent to `RESP::Integer(...)`.
20#[macro_export]
21macro_rules! int {
22 ($x:expr) => {
23 RESP::Integer($x)
24 };
25}
26
27/// `bulk!(...)` is equivalent to `RESP::BulkString(Some(...))`.
28#[macro_export]
29macro_rules! bulk {
30 ($x:expr) => {
31 RESP::BulkString(Some($x))
32 };
33}
34
35/// `bulk_null!()` is equivalent to `RESP::BulkString(None)`.
36#[macro_export]
37macro_rules! bulk_null {
38 () => {
39 RESP::BulkString(None)
40 };
41}
42
43/// `array![...]` is equivalent to `RESP::Array(Some(vec![...]))`.
44#[macro_export]
45macro_rules! array {
46 ($($x:expr),* $(,)?) => {
47 RESP::Array(Some(vec![$($x),*]))
48 };
49}
50
51/// `array_null!()` is equivalent to `RESP::Array(None)`.
52#[macro_export]
53macro_rules! array_null {
54 () => {
55 RESP::Array(None)
56 };
57}