pub struct SerializableWorkflow<C, Input, M = ()> { /* private fields */ }Expand description
A workflow that can be serialized and deserialized.
This is a wrapper around Workflow that carries an internal TaskRegistry,
automatically populated during building. This enables serialization without
manually setting up a separate registry.
§Example
// Build a serializable workflow
let workflow = WorkflowBuilder::new(ctx)
.with_registry() // Enable serialization
.then("step1", |i: u32| async move { Ok(i + 1) })
.then("step2", |i: u32| async move { Ok(i * 2) })
.build()?;
// Serialize
let serialized = workflow.to_serializable();
let json = serde_json::to_string(&serialized)?;
// Deserialize (uses internal registry)
let deserialized: SerializedWorkflowState = serde_json::from_str(&json)?;
let restored = workflow.to_runnable(&deserialized)?;Implementations§
Source§impl<C, Input, M> SerializableWorkflow<C, Input, M>
impl<C, Input, M> SerializableWorkflow<C, Input, M>
Sourcepub fn workflow_id(&self) -> &str
pub fn workflow_id(&self) -> &str
Get the workflow ID.
Sourcepub fn definition_hash(&self) -> &DefinitionHash
pub fn definition_hash(&self) -> &DefinitionHash
Get the definition hash.
Sourcepub fn context(&self) -> &WorkflowContext<C, M>
pub fn context(&self) -> &WorkflowContext<C, M>
Get a reference to the context.
Sourcepub fn continuation(&self) -> &WorkflowContinuation
pub fn continuation(&self) -> &WorkflowContinuation
Get a reference to the continuation.
Sourcepub fn registry(&self) -> &TaskRegistry
pub fn registry(&self) -> &TaskRegistry
Get a reference to the internal task registry.
Sourcepub fn into_parts(self) -> (WorkflowContinuation, TaskRegistry)
pub fn into_parts(self) -> (WorkflowContinuation, TaskRegistry)
Consume the workflow and return its continuation tree and task registry.
Useful for inlining this workflow as a child inside another workflow while merging task registries.
Sourcepub fn to_serializable(&self) -> SerializedWorkflowState
pub fn to_serializable(&self) -> SerializedWorkflowState
Convert to a serializable state representation.
Returns a SerializedWorkflowState that includes the workflow ID,
definition hash, and continuation structure. This can be serialized
and later deserialized to resume the workflow.
Sourcepub fn to_runnable(
&self,
state: &SerializedWorkflowState,
) -> Result<WorkflowContinuation, BuildError>
pub fn to_runnable( &self, state: &SerializedWorkflowState, ) -> Result<WorkflowContinuation, BuildError>
Convert a serialized workflow state to runnable using the internal registry.
§Errors
Returns BuildError::DefinitionMismatch if the definition hash doesn’t
match this workflow’s hash, indicating the serialized state was created with
a different workflow definition.
Returns BuildError::TaskNotFound if any task ID is not in the registry.
Methods from Deref<Target = Workflow<C, Input, M>>§
Sourcepub fn workflow_id(&self) -> &str
pub fn workflow_id(&self) -> &str
Get the workflow name (human-readable).
Sourcepub fn definition_hash(&self) -> &DefinitionHash
pub fn definition_hash(&self) -> &DefinitionHash
Get the definition hash.
This hash is computed from the workflow’s continuation structure and serves as a version identifier. It can be used to detect when a serialized workflow state was created with a different workflow definition.
Sourcepub fn context(&self) -> &WorkflowContext<C, M>
pub fn context(&self) -> &WorkflowContext<C, M>
Get a reference to the context of this workflow.
Sourcepub fn continuation(&self) -> &WorkflowContinuation
pub fn continuation(&self) -> &WorkflowContinuation
Get a reference to the continuation of this workflow.
Sourcepub fn task_index(&self) -> &TaskIndex
pub fn task_index(&self) -> &TaskIndex
Borrow the TaskId → metadata index. Built once at build time.
Sourcepub fn task_index_arc(&self) -> Arc<TaskIndex>
pub fn task_index_arc(&self) -> Arc<TaskIndex>
Clone the shared Arc<TaskIndex> — for callers (FFI / runtime) that
want to hold onto the index alongside the continuation.
Sourcepub fn iter_nodes(&self) -> NodeIter<'_> ⓘ
pub fn iter_nodes(&self) -> NodeIter<'_> ⓘ
Returns a lazy iterator over all nodes in topological (execution) order.
Convenience wrapper around WorkflowContinuation::iter_nodes.