#[non_exhaustive]pub enum FilterExpr {
Simple(Filter),
Compound(CompoundFilter),
}Expand description
A filter expression that can be simple or compound.
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.
Simple(Filter)
A simple field comparison.
Compound(CompoundFilter)
A compound filter with logical operator.
Implementations§
Source§impl FilterExpr
impl FilterExpr
Sourcepub fn parse(json_str: &str) -> Result<Self, ParseError>
pub fn parse(json_str: &str) -> Result<Self, ParseError>
Sourcepub fn parse_bytes(bytes: &[u8]) -> Result<Self, ParseError>
pub fn parse_bytes(bytes: &[u8]) -> Result<Self, ParseError>
Parse a Mongo-style filter from JSON bytes.
Useful when working with raw request bodies.
§Example
use mik_sql::FilterExpr;
let bytes = br#"{"status": {"$in": ["active", "pending"]}}"#;
let filter = FilterExpr::parse_bytes(bytes).unwrap();§Errors
Returns ParseError if the bytes are not valid UTF-8 or valid JSON.
Sourcepub fn from_json(json: &JsonValue) -> Result<Self, ParseError>
pub fn from_json(json: &JsonValue) -> Result<Self, ParseError>
Parse a Mongo-style filter from a parsed JSON value.
Use this when you already have a parsed miniserde::json::Value.
For most cases, prefer parse or parse_bytes.
§Errors
Returns ParseError if the JSON structure is invalid.
Source§impl FilterExpr
impl FilterExpr
Sourcepub fn collect_filters(&self) -> Vec<Filter>
pub fn collect_filters(&self) -> Vec<Filter>
Collect all simple filters from this expression into a vector.
This flattens compound filters, extracting all individual Filter items.
Used by the merge: option in sql_read! to iterate over user filters.
Trait Implementations§
Source§impl Clone for FilterExpr
impl Clone for FilterExpr
Source§fn clone(&self) -> FilterExpr
fn clone(&self) -> FilterExpr
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FilterExpr
impl Debug for FilterExpr
Source§impl IntoIterator for &FilterExpr
impl IntoIterator for &FilterExpr
Source§impl PartialEq for FilterExpr
impl PartialEq for FilterExpr
impl StructuralPartialEq for FilterExpr
Auto Trait Implementations§
impl Freeze for FilterExpr
impl RefUnwindSafe for FilterExpr
impl Send for FilterExpr
impl Sync for FilterExpr
impl Unpin for FilterExpr
impl UnwindSafe for FilterExpr
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