pub enum Expr {
Show 20 variants
Const(Value),
Key(String),
Add(Vec<Expr>),
Mul(Vec<Expr>),
Sub(Box<Expr>, Box<Expr>),
Div(Box<Expr>, Box<Expr>),
Min(Vec<Expr>),
Max(Vec<Expr>),
Eq(Box<Expr>, Box<Expr>),
Gt(Box<Expr>, Box<Expr>),
Gte(Box<Expr>, Box<Expr>),
Lt(Box<Expr>, Box<Expr>),
Lte(Box<Expr>, Box<Expr>),
All(Vec<Expr>),
Any(Vec<Expr>),
Not(Box<Expr>),
If {
when: Box<Expr>,
then: Box<Expr>,
otherwise: Box<Expr>,
},
Coalesce(Vec<Expr>),
Concat(Vec<Expr>),
CountTrue(Vec<String>),
}Expand description
A serializable expression over session state. See the module docs.
Variants§
Const(Value)
A literal value.
Key(String)
Read a state key (with the derived: fallback of State::get).
Add(Vec<Expr>)
Numeric sum of all operands.
Mul(Vec<Expr>)
Numeric product of all operands.
Sub(Box<Expr>, Box<Expr>)
a - b.
Div(Box<Expr>, Box<Expr>)
a / b (None when b is zero).
Min(Vec<Expr>)
Numeric minimum of all operands.
Max(Vec<Expr>)
Numeric maximum of all operands.
Eq(Box<Expr>, Box<Expr>)
Structural equality of two values.
Gt(Box<Expr>, Box<Expr>)
a > b (numeric).
Gte(Box<Expr>, Box<Expr>)
a >= b (numeric).
Lt(Box<Expr>, Box<Expr>)
a < b (numeric).
Lte(Box<Expr>, Box<Expr>)
a <= b (numeric).
All(Vec<Expr>)
true when every operand is true (missing counts as false).
Any(Vec<Expr>)
true when any operand is true (missing counts as false).
Not(Box<Expr>)
Boolean negation (missing counts as false, so not of it is true).
If
Branch on a condition’s truthiness.
Fields
Coalesce(Vec<Expr>)
The first operand that evaluates to a value.
Concat(Vec<Expr>)
String concatenation of all operands (numbers/booleans stringified; missing operands contribute nothing).
CountTrue(Vec<String>)
How many of the named state keys are true.
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn eval(&self, state: &State) -> Option<Value>
pub fn eval(&self, state: &State) -> Option<Value>
Evaluate against state. None means “no value” — a computed variable
skips its write for this cycle.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Expr
impl<'de> Deserialize<'de> for Expr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Expr
impl JsonSchema for Expr
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Expr
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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].