#[non_exhaustive]pub enum Criteria {
Value(Value),
Property(Vec<String>),
Parameter(String),
Unary(UnaryOp, Box<Criteria>),
Binary(BinaryOp, Box<Criteria>, Box<Criteria>),
Group(GroupOp, Vec<Criteria>),
In(Box<Criteria>, Vec<Criteria>),
Between(Box<Criteria>, Box<Criteria>, Box<Criteria>),
IsNull(Box<Criteria>),
Function(Function, Vec<Criteria>),
Custom(String, Vec<Criteria>),
Aggregate(Box<AggregateCall>),
}Expand description
A parsed expression or filter.
use ravenrs_criteria::Criteria;
let c = Criteria::parse("[Price] * [Qty] > 100 And [Active]").expect("valid");
assert_eq!(c.to_string(), "[Price] * [Qty] > 100 And [Active]");
assert_eq!(c.properties(), ["Price", "Qty", "Active"]);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Value(Value)
A literal.
Property(Vec<String>)
A field path, such as Customer.Name; a leading ^ reads the parent row.
Parameter(String)
A parameter, ?Name.
Unary(UnaryOp, Box<Criteria>)
A unary operator.
Binary(BinaryOp, Box<Criteria>, Box<Criteria>)
A binary operator.
Group(GroupOp, Vec<Criteria>)
And or Or over two or more operands.
In(Box<Criteria>, Vec<Criteria>)
value In (a, b, c).
Between(Box<Criteria>, Box<Criteria>, Box<Criteria>)
value Between(low, high).
IsNull(Box<Criteria>)
value Is Null.
Function(Function, Vec<Criteria>)
A built-in function.
Custom(String, Vec<Criteria>)
A function resolved by name when evaluated (see crate::Environment::register).
Aggregate(Box<AggregateCall>)
An aggregate over the current scope, or over a nested collection.
Implementations§
Source§impl Criteria
impl Criteria
Sourcepub fn parse(source: &str) -> Result<Self, ParseError>
pub fn parse(source: &str) -> Result<Self, ParseError>
Parses source; see the crate documentation for the syntax.
Sourcepub fn assignments(source: &str) -> Result<Vec<(String, Self)>, ParseError>
pub fn assignments(source: &str) -> Result<Vec<(String, Self)>, ParseError>
Parses assignments, field = expression; ..., as an update sets fields: each field with
the expression that gives its new value.
use ravenrs_criteria::Criteria;
let set = Criteria::assignments("state = 'done'; [finished] = Today()").unwrap();
assert_eq!(set[0].0, "state");
assert_eq!(set[1].0, "finished");Sourcepub fn properties(&self) -> Vec<String>
pub fn properties(&self) -> Vec<String>
The field paths used, in order, without repeats.
Sourcepub fn parameters(&self) -> Vec<String>
pub fn parameters(&self) -> Vec<String>
The parameter names used, in order, without repeats.
Trait Implementations§
impl StructuralPartialEq for Criteria
Auto Trait Implementations§
impl Freeze for Criteria
impl RefUnwindSafe for Criteria
impl Send for Criteria
impl Sync for Criteria
impl Unpin for Criteria
impl UnsafeUnpin for Criteria
impl UnwindSafe for Criteria
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more