pub struct RuntimeStateMachine { /* private fields */ }Expand description
Concrete runtime state machine with run tracking.
Implementations§
Source§impl RuntimeStateMachine
impl RuntimeStateMachine
Sourcepub fn from_state(state: RuntimeState) -> Self
pub fn from_state(state: RuntimeState) -> Self
Create from an existing state (for recovery).
Sourcepub fn state(&self) -> RuntimeState
pub fn state(&self) -> RuntimeState
Get the current state.
Sourcepub fn current_run_id(&self) -> Option<&RunId>
pub fn current_run_id(&self) -> Option<&RunId>
Get the current run ID (if running).
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the runtime is running.
Sourcepub fn can_process_queue(&self) -> bool
pub fn can_process_queue(&self) -> bool
Check if the runtime can process queued inputs.
True for Idle and Retired (Retired drains existing queue).
Sourcepub fn transition(
&mut self,
next: RuntimeState,
) -> Result<RuntimeState, RuntimeStateTransitionError>
pub fn transition( &mut self, next: RuntimeState, ) -> Result<RuntimeState, RuntimeStateTransitionError>
Transition to a new state.
Sourcepub fn start_run(
&mut self,
run_id: RunId,
) -> Result<(), RuntimeStateTransitionError>
pub fn start_run( &mut self, run_id: RunId, ) -> Result<(), RuntimeStateTransitionError>
Transition to Running with a specific run ID.
Records the pre-run state so complete_run() can return to it
(e.g. Retired → Running → Retired for queue drain).
Sourcepub fn complete_run(&mut self) -> Result<RunId, RuntimeStateTransitionError>
pub fn complete_run(&mut self) -> Result<RunId, RuntimeStateTransitionError>
Transition from Running back to the pre-run state (run completed).
Returns to Retired if the run was started from Retired (drain mode), otherwise returns to Idle.
Sourcepub fn initialize(&mut self) -> Result<(), RuntimeStateTransitionError>
pub fn initialize(&mut self) -> Result<(), RuntimeStateTransitionError>
Mark as initialized (Initializing → Idle).
Sourcepub fn reset_to_idle(
&mut self,
) -> Result<Option<RuntimeState>, RuntimeStateTransitionError>
pub fn reset_to_idle( &mut self, ) -> Result<Option<RuntimeState>, RuntimeStateTransitionError>
Reset the runtime back to Idle after lifecycle cleanup.
Allowed only when not Running. Revives a retired runtime so callers can keep using the same logical runtime instance after abandoning queued work.
Trait Implementations§
Source§impl Clone for RuntimeStateMachine
impl Clone for RuntimeStateMachine
Source§fn clone(&self) -> RuntimeStateMachine
fn clone(&self) -> RuntimeStateMachine
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more