1use crate::values::Value;
5use indexmap::IndexMap;
6use serde::{Deserialize, Serialize};
7use serde_json::Error;
8
9pub type FaunaMap = IndexMap<String, ExprArg>;
10
11#[derive(Clone, Debug, Deserialize, Serialize)]
12#[serde(untagged)]
13pub enum ExprArg {
14 Array(Vec<Box<ExprArg>>),
15
16 String(String),
18 Integer(i64),
19 Float(f64),
20 Bool(bool),
21
22 Value(Value),
24
25 Object(FaunaMap),
26
27 Null(Option<()>),
28}
29
30pub trait IntoExpr {
31 fn to_expr(self) -> Result<ExprArg, Error>;
32}
33
34impl IntoExpr for ExprArg {
35 fn to_expr(self) -> Result<ExprArg, Error> {
36 Ok(self)
37 }
38}
39
40impl IntoExpr for &str {
41 fn to_expr(self) -> Result<ExprArg, Error> {
42 serde_json::from_str(self)
43 }
44}
45
46impl IntoExpr for String {
47 fn to_expr(self) -> Result<ExprArg, Error> {
48 serde_json::from_str(&self)
49 }
50}