Skip to main content

Flow

Struct Flow 

Source
pub struct Flow {
    pub name: Option<String>,
    pub description: Option<String>,
    pub version: Option<String>,
    pub schemas: FlowSchema,
    pub steps: Vec<Step>,
    pub output: ValueExpr,
    pub test: Option<TestConfig>,
    pub examples: Option<Vec<ExampleInput>>,
    pub metadata: HashMap<String, Value>,
}
Expand description

A workflow consisting of a sequence of steps and their outputs.

A flow represents a complete workflow that can be executed. It contains:

  • A sequence of steps to execute
  • Named outputs that can reference step outputs

Flows should not be cloned. They should generally be stored and passed as a reference or inside an Arc.

Fields§

§name: Option<String>

The name of the flow.

§description: Option<String>

The description of the flow.

§version: Option<String>

The version of the flow.

§schemas: FlowSchema

Consolidated schema information for the flow. Contains input/output schemas, step output schemas, and shared $defs.

§steps: Vec<Step>

The steps to execute for the flow.

§output: ValueExpr

The outputs of the flow, mapping output names to their values.

§test: Option<TestConfig>

Test configuration for the flow.

§examples: Option<Vec<ExampleInput>>

Example inputs for the workflow that can be used for testing and UI dropdowns.

§metadata: HashMap<String, Value>

Extensible metadata for the flow that can be used by tools and frameworks.

Implementations§

Source§

impl Flow

Source

pub fn builder() -> FlowBuilder

Create a new FlowBuilder.

Source§

impl Flow

Source

pub fn slow_clone(&self) -> Self

Create a clone of this flow.

Warning: This method performs a deep clone of the entire workflow structure, including all steps, metadata, and configurations. This can be expensive for large workflows.

§Performance
  • Cloning large workflows with many steps can be slow
  • Consider using Arc<Flow> for shared ownership instead
  • Only use this when you need to modify the workflow structure
§Example
use stepflow_core::workflow::Flow;

let original_flow = Flow::default();
let cloned_flow = original_flow.slow_clone();
Source

pub fn name(&self) -> Option<&str>

Source

pub fn description(&self) -> Option<&str>

Source

pub fn version(&self) -> Option<&str>

Source

pub fn metadata(&self) -> &HashMap<String, Value>

Source

pub fn steps(&self) -> &[Step]

Returns a reference to all steps in the flow.

Source

pub fn examples(&self) -> &[ExampleInput]

Source

pub fn variables(&self) -> Option<VariableSchema>

Get the variable schema for the flow.

This constructs a VariableSchema from the schema definition, extracting runtime metadata like defaults, secrets, and required variables.

Source

pub fn variable_schema(&self) -> Option<&SchemaRef>

Get a reference to the variable schema (raw SchemaRef).

Source

pub fn step(&self, index: usize) -> &Step

Returns a reference to the step at the given index.

§Panics

Panics if the index is out of bounds.

Source

pub fn step_mut(&mut self, index: usize) -> &mut Step

Returns a mutable reference to the step at the given index.

§Panics

Panics if the index is out of bounds.

Source

pub fn output(&self) -> &ValueExpr

Returns a reference to the flow’s output value.

Source

pub fn test(&self) -> Option<&TestConfig>

Source

pub fn test_mut(&mut self) -> Option<&mut TestConfig>

Source

pub fn schemas(&self) -> &FlowSchema

Get the flow’s schema information.

Source

pub fn schemas_mut(&mut self) -> &mut FlowSchema

Get a mutable reference to the flow’s schema information.

Source

pub fn input_schema(&self) -> Option<&SchemaRef>

Get the flow’s input schema.

Source

pub fn set_input_schema(&mut self, input_schema: Option<SchemaRef>)

Set the flow’s input schema.

Source

pub fn output_schema(&self) -> Option<&SchemaRef>

Get the flow’s output schema.

Source

pub fn set_output_schema(&mut self, output_schema: Option<SchemaRef>)

Set the flow’s output schema.

Source

pub fn step_output_schema(&self, step_id: &str) -> Option<&SchemaRef>

Get the output schema for a specific step.

Source

pub fn set_step_output_schema( &mut self, step_id: String, step_schema: SchemaRef, )

Set the output schema for a specific step.

Source

pub fn get_all_examples(&self) -> Vec<ExampleInput>

Get all example inputs, including those derived from test cases.

Trait Implementations§

Source§

impl Clone for Flow

Source§

fn clone(&self) -> Flow

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 Flow

Source§

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

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

impl Default for Flow

Source§

fn default() -> Flow

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

impl<'de> Deserialize<'de> for Flow

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 From<Flow> for FlowRef

Source§

fn from(flow: Flow) -> Self

Converts to this type from the input type.
Source§

impl JsonSchema for Flow

Source§

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

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

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

Returns a string that uniquely identifies the schema produced by this type. 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§

impl PartialEq for Flow

Source§

fn eq(&self, other: &Flow) -> 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 Flow

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 Flow

Auto Trait Implementations§

§

impl Freeze for Flow

§

impl RefUnwindSafe for Flow

§

impl Send for Flow

§

impl Sync for Flow

§

impl Unpin for Flow

§

impl UnsafeUnpin for Flow

§

impl UnwindSafe for Flow

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