Expr

Struct Expr 

Source
pub struct Expr;
Expand description

Fluent builder for constructing expression trees

Provides a convenient API for building complex expressions without excessive nesting of Box::new() calls.

§Example

use solverforge_core::wasm::{Expression, Expr};
use solverforge_core::wasm::FieldAccessExt;

// Build: param(0).employee != null
let shift = Expr::param(0);
let employee = shift.get("Shift", "employee");
let predicate = Expr::is_not_null(employee);

Implementations§

Source§

impl Expr

Source

pub fn int(value: i64) -> Expression

Create an integer literal

Source

pub fn bool(value: bool) -> Expression

Create a boolean literal

Source

pub fn null() -> Expression

Create a null literal

Source

pub fn param(index: u32) -> Expression

Access a function parameter by index

Source

pub fn eq(left: Expression, right: Expression) -> Expression

Equal comparison (==)

Source

pub fn ne(left: Expression, right: Expression) -> Expression

Not equal comparison (!=)

Source

pub fn lt(left: Expression, right: Expression) -> Expression

Less than comparison (<)

Source

pub fn le(left: Expression, right: Expression) -> Expression

Less than or equal comparison (<=)

Source

pub fn gt(left: Expression, right: Expression) -> Expression

Greater than comparison (>)

Source

pub fn ge(left: Expression, right: Expression) -> Expression

Greater than or equal comparison (>=)

Source

pub fn and(left: Expression, right: Expression) -> Expression

Logical AND (&&)

Source

pub fn or(left: Expression, right: Expression) -> Expression

Logical OR (||)

Source

pub fn not(operand: Expression) -> Expression

Logical NOT (!)

Source

pub fn is_null(operand: Expression) -> Expression

Null check (is null)

Source

pub fn is_not_null(operand: Expression) -> Expression

Not-null check (is not null)

Source

pub fn add(left: Expression, right: Expression) -> Expression

Addition (+)

Source

pub fn sub(left: Expression, right: Expression) -> Expression

Subtraction (-)

Source

pub fn mul(left: Expression, right: Expression) -> Expression

Multiplication (*)

Source

pub fn div(left: Expression, right: Expression) -> Expression

Division (/)

Source

pub fn host_call( function_name: impl Into<String>, args: Vec<Expression>, ) -> Expression

Call a host function

Source

pub fn list_contains(list: Expression, element: Expression) -> Expression

Check if a list contains an element

Generates a loop that iterates through the list and checks for equality. Returns true if the element is found, false otherwise.

Source

pub fn string_equals(left: Expression, right: Expression) -> Expression

String equality via host function

Equivalent to: hstringEquals(left, right)

Source

pub fn ranges_overlap( start1: Expression, end1: Expression, start2: Expression, end2: Expression, ) -> Expression

Check if two time ranges overlap

Equivalent to: start1 < end2 && start2 < end1

Source

pub fn if_then_else( condition: Expression, then_branch: Expression, else_branch: Expression, ) -> Expression

If-then-else conditional expression

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnwindSafe for Expr

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more