Struct Filter
pub struct Filter {
pub expr: Option<Expr>,
}Expand description
A WHERE clause filter for statements.
Wraps an optional expression. When expr is None, the filter matches all
rows (equivalent to WHERE true). Filters can be combined with
add_filter, which AND-s the expressions together.
§Examples
use toasty_core::stmt::Filter;
// An empty filter matches everything
let filter = Filter::default();
assert!(filter.expr.is_none());
// Filter::ALL is a const alias for the same thing
assert!(Filter::ALL.expr.is_none());Fields§
§expr: Option<Expr>The filter expression, or None to match all rows.
Implementations§
§impl Filter
impl Filter
pub fn and(lhs: impl Into<Filter>, rhs: impl Into<Filter>) -> Filter
pub fn and(lhs: impl Into<Filter>, rhs: impl Into<Filter>) -> Filter
Creates a filter by AND-ing two filters together.
pub fn as_expr(&self) -> &Expr
pub fn as_expr(&self) -> &Expr
Returns the filter expression.
When no expression is set, returns true, which matches all rows.
pub fn set(&mut self, expr: impl Into<Expr>)
pub fn set(&mut self, expr: impl Into<Expr>)
Replaces the filter expression with the given expression.
pub fn add_filter(&mut self, filter: impl Into<Filter>)
pub fn add_filter(&mut self, filter: impl Into<Filter>)
Adds a filter by AND-ing it with the current expression.
If either filter is empty, the other is used directly.
Trait Implementations§
impl StructuralPartialEq for Filter
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
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