Skip to main content

ValueExpr

Enum ValueExpr 

Source
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" }

Fields

§step: String
§

Input

Workflow input: { $input: "path" } where path can be “$” for root

Fields

§input: JsonPath
§

Variable

Variable: { $variable: "$.var.path", default: ... }

Fields

§variable: JsonPath
§

EscapedLiteral

Escape hatch: { $literal: {...} } - prevents recursive parsing

Fields

§literal: Value
§

If

Conditional expression: { $if: <condition>, then: <expr>, else?: <expr> } Returns then value if condition is truthy, otherwise else value (defaults to null)

Fields

§condition: Box<ValueExpr>
§else_expr: Option<Box<ValueExpr>>
§

Coalesce

Coalesce: { $coalesce: [<expr1>, <expr2>, ...] } Returns first non-skipped, non-null value from the list

Fields

§values: Vec<ValueExpr>
§

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

Source

pub fn step(step_id: impl Into<String>, path: JsonPath) -> Self

Create a step reference expression

Source

pub fn step_output(step_id: impl Into<String>) -> Self

Create a step reference without a path (for compatibility with old code)

Source

pub fn workflow_input(path: JsonPath) -> Self

Create a workflow input reference expression

Source

pub fn variable( name: impl Into<String>, default: Option<Box<ValueExpr>>, ) -> Self

Create a variable reference expression

Source

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.

Source

pub fn array(values: Vec<ValueExpr>) -> Self

Create an array value expression

Source

pub fn object(values: Vec<(String, ValueExpr)>) -> Self

Create an object value expression from key-value pairs

Source

pub fn escaped_literal(value: Value) -> Self

Create an escaped literal expression

Source

pub fn if_expr( condition: ValueExpr, then: ValueExpr, else_expr: Option<ValueExpr>, ) -> Self

Create a conditional expression

Source

pub fn coalesce(values: Vec<ValueExpr>) -> Self

Create a coalesce expression

Source

pub fn null() -> Self

Create a null literal expression

Source

pub fn is_null(&self) -> bool

Check if this expression is a null literal

Source

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 } }:

  1. First call (foo not complete): returns {foo_index}
  2. After foo completes (truthy): returns {bar_index}
  3. After bar completes: returns {} (ready!)
Source

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 ($step references)
  • Workflow input ($input references)
  • Variables ($variable references)

Trait Implementations§

Source§

impl Clone for ValueExpr

Source§

fn clone(&self) -> ValueExpr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValueExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ValueExpr

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ValueExpr

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for ValueExpr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonSchema for ValueExpr

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn json_schema(_generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl PartialEq for ValueExpr

Source§

fn eq(&self, other: &ValueExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ValueExpr

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ValueExpr

Source§

impl StructuralPartialEq for ValueExpr

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Erased for T