Skip to main content

WorkflowStep

Enum WorkflowStep 

Source
pub enum WorkflowStep {
    Query {
        cmd_json: String,
        store_as: Option<String>,
    },
    Notify {
        channel: ChannelKind,
        template: String,
        recipient_key: String,
        payload_key: Option<String>,
    },
    Wait {
        event: String,
        timeout: Duration,
        on_timeout: Vec<WorkflowStep>,
    },
    Branch {
        condition_key: String,
        branches: Vec<(String, Vec<WorkflowStep>)>,
        default: Vec<WorkflowStep>,
    },
    BranchWhen {
        condition_key: String,
        branches: Vec<(WorkflowBranchCondition, Vec<WorkflowStep>)>,
        default: Vec<WorkflowStep>,
    },
    ForEach {
        list_key: String,
        steps: Vec<WorkflowStep>,
    },
    Transition {
        to: String,
    },
    Log {
        message: String,
    },
    Charge {
        provider: PaymentKind,
        amount_key: String,
        reference_key: String,
        description_key: Option<String>,
        payment_method_key: Option<String>,
        order_origin_key: Option<String>,
        store_as: Option<String>,
    },
}
Expand description

A single step in a workflow execution.

Variants§

§

Query

Execute a QAIL query against the database. The cmd_json field stores QAIL wire text (qail_core::wire::encode_cmd_text). The store_as key saves the result into WorkflowContext for later steps.

Fields

§cmd_json: String

QAIL command encoded in QAIL wire text.

§store_as: Option<String>

Optional key to store query results in context

§

Notify

Send a notification via a channel (WhatsApp, Email, SMS, Push).

Fields

§channel: ChannelKind

Which channel to send through

§template: String

Template name (e.g., “opportunity_alert”, “booking_confirmed”)

§recipient_key: String

Context key that resolves to the recipient address

§payload_key: Option<String>

Optional extra payload (template variables)

§

Wait

Wait for an external event (webhook callback, user action, timeout).

Fields

§event: String

Event key to listen for (matched against incoming webhook/callback)

§timeout: Duration

Maximum time to wait before triggering on_timeout

§on_timeout: Vec<WorkflowStep>

Steps to execute if timeout is reached

§

Branch

Conditional branching based on a context value.

Fields

§condition_key: String

Context key to evaluate

§branches: Vec<(String, Vec<WorkflowStep>)>

Map of value → steps to execute

§default: Vec<WorkflowStep>

Default steps if no branch matches

§

BranchWhen

Conditional branching with richer predicates.

Fields

§condition_key: String

Context key to evaluate

§branches: Vec<(WorkflowBranchCondition, Vec<WorkflowStep>)>

Ordered predicates and steps. The first matching predicate is selected.

§default: Vec<WorkflowStep>

Default steps if no predicate matches

§

ForEach

Execute steps for each item in a context list.

Fields

§list_key: String

Context key containing a JSON array

§steps: Vec<WorkflowStep>

Steps to execute per item (item available as “item” in context)

§

Transition

Transition to a new workflow state.

Fields

§to: String

Target state name

§

Log

Log a message (useful for debugging/audit trails).

Fields

§message: String

Message template (can reference context keys with {key})

§

Charge

Create a payment charge via a payment provider.

Resolves amount and reference from context, calls the provider, and stores a redacted PaymentDisplay in context for downstream steps.

Fields

§provider: PaymentKind

Which payment provider to use

§amount_key: String

Context key that resolves to the charge amount (i64)

§reference_key: String

Context key that resolves to the reference ID (string)

§description_key: Option<String>

Optional context key for description

§payment_method_key: Option<String>

Optional context key for payment method override

§order_origin_key: Option<String>

Optional context key for the order origin (whatsapp, mcp, web, ios_app, android_app, or api).

§store_as: Option<String>

Optional key to store redacted payment display details in context

Implementations§

Source§

impl WorkflowStep

Source

pub fn query(cmd: &Qail, store_as: Option<&str>) -> Self

Create a Query step from a Qail command.

Source

pub fn notify(channel: ChannelKind, template: &str, recipient_key: &str) -> Self

Create a Notify step.

Source

pub fn notify_with_payload( channel: ChannelKind, template: &str, recipient_key: &str, payload_key: &str, ) -> Self

Create a Notify step with payload.

Source

pub fn wait(event: &str, timeout: Duration) -> Self

Create a Wait step.

Source

pub fn wait_or( event: &str, timeout: Duration, on_timeout: Vec<WorkflowStep>, ) -> Self

Create a Wait step with timeout fallback.

Source

pub fn for_each(list_key: &str, steps: Vec<WorkflowStep>) -> Self

Create a ForEach step.

Source

pub fn transition(to: &str) -> Self

Create a Transition step.

Source

pub fn log(message: &str) -> Self

Create a Log step.

Source

pub fn charge( provider: PaymentKind, amount_key: &str, reference_key: &str, store_as: Option<&str>, ) -> Self

Create a Charge step.

Source

pub fn charge_with( provider: PaymentKind, amount_key: &str, reference_key: &str, description_key: Option<&str>, payment_method_key: Option<&str>, store_as: Option<&str>, ) -> Self

Create a Charge step with full options.

Source

pub fn charge_with_origin( provider: PaymentKind, amount_key: &str, reference_key: &str, description_key: Option<&str>, payment_method_key: Option<&str>, order_origin_key: Option<&str>, store_as: Option<&str>, ) -> Self

Create a Charge step with explicit source-channel tracking.

Source

pub fn branch( condition_key: &str, branches: Vec<(&str, Vec<WorkflowStep>)>, default: Vec<WorkflowStep>, ) -> Self

Create a Branch step.

Source

pub fn branch_when( condition_key: &str, branches: Vec<(WorkflowBranchCondition, Vec<WorkflowStep>)>, default: Vec<WorkflowStep>, ) -> Self

Create a BranchWhen step with richer predicates.

Trait Implementations§

Source§

impl Clone for WorkflowStep

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkflowStep

Source§

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

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

impl<'de> Deserialize<'de> for WorkflowStep

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 Eq for WorkflowStep

Source§

impl PartialEq for WorkflowStep

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for WorkflowStep

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 StructuralPartialEq for WorkflowStep

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> ColumnValue<Value> for T

Source§

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.