pub enum ValueExpr {
Step {
step: String,
path: JsonPath,
},
Input {
input: JsonPath,
},
Variable {
variable: JsonPath,
default: Option<Box<ValueExpr>>,
},
EscapedLiteral {
literal: Value,
},
If {
condition: Box<ValueExpr>,
then: Box<ValueExpr>,
else_expr: Option<Box<ValueExpr>>,
},
Coalesce {
values: Vec<ValueExpr>,
},
Array(Vec<ValueExpr>),
Object(Vec<(String, ValueExpr)>),
Literal(Value),
}Expand description
A value expression that can contain literal data or references to other values.
This is the unified type for all workflow inputs, outputs, and data flow. Expressions can be:
- References to other values (
$step,$input,$variable) - Composable structures (arrays and objects containing expressions)
- Literal values (null, bool, number, string - any primitive JSON value)
- Escaped literals (
$literal) to prevent expansion
Variants§
Step
Step reference: { $step: "step_id", path: "optional.path" }
Input
Workflow input: { $input: "path" } where path can be “$” for root
Variable
Variable: { $variable: "$.var.path", default: ... }
EscapedLiteral
Escape hatch: { $literal: {...} } - prevents recursive parsing
If
Conditional expression: { $if: <condition>, then: <expr>, else?: <expr> }
Returns then value if condition is truthy, otherwise else value (defaults to null)
Coalesce
Coalesce: { $coalesce: [<expr1>, <expr2>, ...] }
Returns first non-skipped, non-null value from the list
Array(Vec<ValueExpr>)
JSON array where each element can be an expression
Object(Vec<(String, ValueExpr)>)
JSON object where each value can be an expression Uses Vec instead of Map for efficiency and to enable hashability
Literal(Value)
Literal JSON value (null, bool, number, string) Note: Literal objects and arrays are parsed as Object/Array variants
Implementations§
Source§impl ValueExpr
impl ValueExpr
Sourcepub fn step(step_id: impl Into<String>, path: JsonPath) -> Self
pub fn step(step_id: impl Into<String>, path: JsonPath) -> Self
Create a step reference expression
Sourcepub fn step_output(step_id: impl Into<String>) -> Self
pub fn step_output(step_id: impl Into<String>) -> Self
Create a step reference without a path (for compatibility with old code)
Sourcepub fn workflow_input(path: JsonPath) -> Self
pub fn workflow_input(path: JsonPath) -> Self
Create a workflow input reference expression
Sourcepub fn variable(
name: impl Into<String>,
default: Option<Box<ValueExpr>>,
) -> Self
pub fn variable( name: impl Into<String>, default: Option<Box<ValueExpr>>, ) -> Self
Create a variable reference expression
Sourcepub fn literal(value: Value) -> Self
pub fn literal(value: Value) -> Self
Create a literal value expression from a serde_json::Value
Arrays and objects are recursively converted to composable ValueExpr structures. Primitives (null, bool, number, string) become Literal variants.
Sourcepub fn object(values: Vec<(String, ValueExpr)>) -> Self
pub fn object(values: Vec<(String, ValueExpr)>) -> Self
Create an object value expression from key-value pairs
Sourcepub fn escaped_literal(value: Value) -> Self
pub fn escaped_literal(value: Value) -> Self
Create an escaped literal expression
Sourcepub fn if_expr(
condition: ValueExpr,
then: ValueExpr,
else_expr: Option<ValueExpr>,
) -> Self
pub fn if_expr( condition: ValueExpr, then: ValueExpr, else_expr: Option<ValueExpr>, ) -> Self
Create a conditional expression
Sourcepub fn needed_steps(&self, ctx: &impl StepContext) -> BitSet
pub fn needed_steps(&self, ctx: &impl StepContext) -> BitSet
Returns the set of step indices needed to evaluate this expression.
An empty set means the expression is ready to be fully resolved.
This method evaluates lazily - for conditional expressions like $if,
it only returns the condition’s dependencies until the condition can
be evaluated, then returns the appropriate branch’s dependencies.
§Arguments
ctx- Context providing step completion state and results
§Example
For { $if: { $step: foo }, then: { $step: bar }, else: { $step: baz } }:
- First call (foo not complete): returns
{foo_index} - After foo completes (truthy): returns
{bar_index} - After bar completes: returns
{}(ready!)
Sourcepub fn resolve(&self, ctx: &impl StepContext) -> FlowResult
pub fn resolve(&self, ctx: &impl StepContext) -> FlowResult
Resolve this expression using the provided context.
This should only be called when needed_steps() returns an empty set,
meaning all required step results are available in the context.
The context provides access to:
- Step results (
$stepreferences) - Workflow input (
$inputreferences) - Variables (
$variablereferences)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ValueExpr
impl<'de> Deserialize<'de> for ValueExpr
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 ValueExpr
impl JsonSchema for ValueExpr
Source§fn json_schema(_generator: &mut SchemaGenerator) -> Schema
fn json_schema(_generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl Eq for ValueExpr
impl StructuralPartialEq for ValueExpr
Auto Trait Implementations§
impl Freeze for ValueExpr
impl RefUnwindSafe for ValueExpr
impl Send for ValueExpr
impl Sync for ValueExpr
impl Unpin for ValueExpr
impl UnsafeUnpin for ValueExpr
impl UnwindSafe for ValueExpr
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.