use std::borrow::Cow;
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct And<'a> {
pub operands: Vec<Box<Expr<'a>>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct Between<'a> {
pub field: Cow<'a, str>,
pub lo: Value<'a>,
pub hi: Value<'a>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub enum BinOp {
Eq,
Neq,
Contains,
NotContains,
StartsWith,
NotStartsWith,
EndsWith,
NotEndsWith,
Gt,
Gte,
Lt,
Lte,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub enum Boolean {
True,
False,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct Compare<'a> {
pub field: Cow<'a, str>,
pub op: BinOp,
pub value: Value<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct Empty<'a> {
pub field: Cow<'a, str>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub enum EmptyKind {
Empty,
Null,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub enum Expr<'a> {
And(Box<And<'a>>),
Or(Box<Or<'a>>),
Not(Box<Expr<'a>>),
Compare(Compare<'a>),
Between(Between<'a>),
NotBetween(Between<'a>),
In(In<'a>),
NotIn(In<'a>),
IsEmpty(Empty<'a>),
IsNull(Empty<'a>),
IsNotEmpty(Empty<'a>),
IsNotNull(Empty<'a>),
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct In<'a> {
pub field: Cow<'a, str>,
pub values: Vec<Value<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct Now {}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct Or<'a> {
pub operands: Vec<Box<Expr<'a>>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct Participant<'a> {
pub r#type: Cow<'a, str>,
pub id: Cow<'a, str>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub enum Value<'a> {
String(Cow<'a, str>),
Enum(Cow<'a, str>),
Integer(Cow<'a, str>),
Float(Cow<'a, str>),
Boolean(Boolean),
Date(Cow<'a, str>),
DateTime(Cow<'a, str>),
Participant(Participant<'a>),
Now(Now),
}