1use redis::{RedisResult, ErrorKind, RedisError};
2
3use crate::{FromGraphValue, GraphValue};
4
5
6macro_rules! apply_macro {
8 ($m:tt, $($x:ty),+) => {
9 $(
10 $m!($x);
11 )*
12 };
13}
14
15pub(crate) use apply_macro;
16
17#[inline(always)]
19pub fn from_graph_value<T: FromGraphValue>(value: GraphValue) -> RedisResult<T> {
20 FromGraphValue::from_graph_value(value)
21}
22
23pub fn create_rediserror(desc: &str) -> RedisError {
25 (
26 ErrorKind::TypeError,
27 "Parsing Error",
28 desc.to_owned()
29 ).into()
30}
31
32#[macro_export]
53macro_rules! query {
54 ( $s:expr $(, $ro:literal)?) => {{
55 #[allow(unused_assignments, unused_mut)]
56 let mut read_only = false;
57 $(
58 read_only = $ro;
59 )?
60 $crate::GraphQuery {
61 query: $s, read_only, params: vec![]
62 }
63 }};
64 ( $s:expr, { $( $k:expr => $v:expr ),* } $(, $ro:literal)?) => {{
65 #[allow(unused_assignments, unused_mut)]
66 let mut read_only = false;
67 $(
68 read_only = $ro;
69 )?
70 $crate::GraphQuery {
71 query: $s, read_only, params: vec![$(
72 ($k, $crate::Parameter::from($v)),
73 )*]
74 }
75 }}
76}