pub struct WorkflowBuilder<D: WorkflowData> { /* private fields */ }Expand description
Fluent builder for constructing workflow definitions.
Uses an owned-self pattern: each method consumes and returns the builder, avoiding lifetime issues with mutable borrows.
§Example
ⓘ
let def = WorkflowBuilder::<MyData>::new()
.start_with::<StepA>()
.name("Step A")
.then::<StepB>()
.name("Step B")
.end_workflow()
.build("my-workflow", 1);Implementations§
Source§impl<D: WorkflowData> WorkflowBuilder<D>
impl<D: WorkflowData> WorkflowBuilder<D>
pub fn new() -> Self
Sourcepub fn start_with<S: StepBody + Default + 'static>(self) -> StepBuilder<D>
pub fn start_with<S: StepBody + Default + 'static>(self) -> StepBuilder<D>
Add the first step of the workflow.
Sourcepub fn add_step(&mut self, step_type: &str) -> usize
pub fn add_step(&mut self, step_type: &str) -> usize
Add a step by type name. Used by container builder closures.
Sourcepub fn build(self, id: impl Into<String>, version: u32) -> WorkflowDefinition
pub fn build(self, id: impl Into<String>, version: u32) -> WorkflowDefinition
Compile the builder into a WorkflowDefinition.
Sourcepub fn build_with_closures(
self,
id: impl Into<String>,
version: u32,
) -> (WorkflowDefinition, HashMap<usize, Box<dyn Fn() -> ExecutionResult + Send + Sync>>)
pub fn build_with_closures( self, id: impl Into<String>, version: u32, ) -> (WorkflowDefinition, HashMap<usize, Box<dyn Fn() -> ExecutionResult + Send + Sync>>)
Compile the builder into a WorkflowDefinition and return any inline closures keyed by step id.
Sourcepub fn register_inline_steps(
self,
registry: &mut StepRegistry,
id: impl Into<String>,
version: u32,
) -> WorkflowDefinition
pub fn register_inline_steps( self, registry: &mut StepRegistry, id: impl Into<String>, version: u32, ) -> WorkflowDefinition
Register all inline closures from this builder into the given step registry.
Each inline closure is registered under a unique key derived from the
InlineStep type name and step id.
Trait Implementations§
Source§impl<D: WorkflowData> Default for WorkflowBuilder<D>
impl<D: WorkflowData> Default for WorkflowBuilder<D>
Auto Trait Implementations§
impl<D> Freeze for WorkflowBuilder<D>
impl<D> !RefUnwindSafe for WorkflowBuilder<D>
impl<D> Send for WorkflowBuilder<D>
impl<D> Sync for WorkflowBuilder<D>
impl<D> Unpin for WorkflowBuilder<D>where
D: Unpin,
impl<D> UnsafeUnpin for WorkflowBuilder<D>
impl<D> !UnwindSafe for WorkflowBuilder<D>
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
Mutably borrows from an owned value. Read more