pub struct Expr<T> { /* private fields */ }Expand description
A typed expression in the Toasty query language.
Expr<T> wraps an untyped AST expression node and tags it with a Rust type
T that represents the expression’s value type. Common instantiations:
Expr<bool>— a boolean filter expression (comparisons,and,or,not).Expr<String>,Expr<i64>, etc. — scalar value expressions.Expr<Option<T>>— a nullable expression withis_noneandis_somehelpers.Expr<List<T>>— a list expression (seeExpr::list).
Expressions are built from [Path] comparisons, literal values via
IntoExpr, and combinators like and and or.
Implementations§
Source§impl<T> Expr<T>
impl<T> Expr<T>
Sourcepub fn from_untyped(untyped: impl Into<Expr>) -> Expr<T>
pub fn from_untyped(untyped: impl Into<Expr>) -> Expr<T>
Wrap a raw untyped expression, tagging it with type T.
§Examples
let expr = Expr::<i64>::from_untyped(core_stmt::Expr::Value(
core_stmt::Value::from(42_i64),
));Sourcepub fn cast<U>(self) -> Expr<U>
pub fn cast<U>(self) -> Expr<U>
Re-tag this expression with a different type U.
This performs no runtime conversion — the underlying AST node is
unchanged. Use this when the type system needs a different type tag but
the expression itself is compatible (e.g., widening Expr<T> to
Expr<Option<T>>).
§Examples
let expr: Expr<i64> = 42_i64.into_expr();
let optional: Expr<Option<i64>> = expr.cast();Sourcepub fn ne(self, rhs: impl IntoExpr<T>) -> Expr<bool>
pub fn ne(self, rhs: impl IntoExpr<T>) -> Expr<bool>
Test whether this expression does not equal rhs.
Sourcepub fn gt(self, rhs: impl IntoExpr<T>) -> Expr<bool>
pub fn gt(self, rhs: impl IntoExpr<T>) -> Expr<bool>
Test whether this expression is greater than rhs.
Sourcepub fn ge(self, rhs: impl IntoExpr<T>) -> Expr<bool>
pub fn ge(self, rhs: impl IntoExpr<T>) -> Expr<bool>
Test whether this expression is greater than or equal to rhs.
Source§impl<T> Expr<List<T>>
impl<T> Expr<List<T>>
Source§impl Expr<bool>
impl Expr<bool>
Sourcepub fn and(self, rhs: impl IntoExpr<bool>) -> Expr<bool>
pub fn and(self, rhs: impl IntoExpr<bool>) -> Expr<bool>
Combine two boolean expressions with logical AND.
§Examples
let filter = User::fields().name().eq("Alice")
.and(User::fields().age().gt(18));Sourcepub fn and_all<E>(exprs: impl IntoIterator<Item = E>) -> Expr<bool>
pub fn and_all<E>(exprs: impl IntoIterator<Item = E>) -> Expr<bool>
Combine an iterator of boolean expressions with logical AND.
Returns true (no filter) when the iterator is empty.
§Examples
use toasty::stmt::Expr;
let conditions = vec![
User::fields().name().eq("Alice"),
User::fields().age().gt(18),
];
let combined = Expr::and_all(conditions);Sourcepub fn or(self, rhs: impl IntoExpr<bool>) -> Expr<bool>
pub fn or(self, rhs: impl IntoExpr<bool>) -> Expr<bool>
Combine two boolean expressions with logical OR.
§Examples
let filter = User::fields().name().eq("Alice")
.or(User::fields().name().eq("Bob"));Trait Implementations§
Source§impl<T> Assign<T> for Expr<T>
impl<T> Assign<T> for Expr<T>
Source§fn into_assignment(self) -> Assignment<T>
fn into_assignment(self) -> Assignment<T>
Assignment<T> value.Source§fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
Assignments] map at
the specified projection.