StateManager

Struct StateManager 

Source
pub struct StateManager;
Expand description

Manages workflow execution state

Implementations§

Source§

impl StateManager

Source

pub fn create_state(workflow: &Workflow) -> WorkflowState

Create a new workflow state

Source

pub fn start_workflow(state: &mut WorkflowState)

Update workflow state to running

Source

pub fn start_step(state: &mut WorkflowState, step_id: String)

Mark a step as started

Source

pub fn complete_step( state: &mut WorkflowState, step_id: String, output: Option<Value>, duration_ms: u64, )

Mark a step as completed

Source

pub fn fail_step( state: &mut WorkflowState, step_id: String, error: String, duration_ms: u64, )

Mark a step as failed

Source

pub fn skip_step(state: &mut WorkflowState, step_id: String)

Mark a step as skipped

Source

pub fn wait_for_approval(state: &mut WorkflowState)

Mark workflow as waiting for approval

Source

pub fn complete_workflow(state: &mut WorkflowState)

Mark workflow as completed

Source

pub fn fail_workflow(state: &mut WorkflowState)

Mark workflow as failed

Source

pub fn cancel_workflow(state: &mut WorkflowState)

Mark workflow as cancelled

Source

pub fn pause_workflow(state: &mut WorkflowState) -> WorkflowResult<()>

Pause workflow execution at current step

Source

pub fn resume_workflow(state: &mut WorkflowState) -> WorkflowResult<()>

Resume workflow execution from paused step

Source

pub fn is_step_completed(state: &WorkflowState, step_id: &str) -> bool

Check if a step has already been completed

Source

pub fn get_next_step_to_execute( state: &WorkflowState, available_steps: &[String], ) -> Option<String>

Get the next step to execute (skipping completed steps)

Source

pub fn persist_state(state: &WorkflowState, path: &Path) -> WorkflowResult<()>

Persist workflow state to file (YAML format)

Source

pub fn persist_state_json( state: &WorkflowState, path: &Path, ) -> WorkflowResult<()>

Persist workflow state to file (JSON format)

Source

pub fn load_state(path: &Path) -> WorkflowResult<WorkflowState>

Load workflow state from file (auto-detects YAML or JSON)

Source

pub fn validate_state(state: &WorkflowState) -> WorkflowResult<()>

Validate state integrity

Source

pub fn load_state_validated(path: &Path) -> WorkflowResult<WorkflowState>

Load state with validation

Source

pub fn load_state_with_recovery(path: &Path) -> WorkflowResult<WorkflowState>

Handle corrupted state file gracefully

Source

pub fn get_progress(state: &WorkflowState, total_steps: usize) -> u32

Get progress percentage (0-100)

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