pub trait StateTransition {
type Context;
type SMResult;
// Required methods
fn step(
&mut self,
context: &Self::Context,
) -> Result<TransitionResult<Self::SMResult>>;
fn finalize(&mut self, context: &Self::Context) -> Result<()>;
fn is_finalized(&self) -> bool;
}Expand description
A generic trait for state machines.
Required Associated Types§
Required Methods§
Sourcefn step(
&mut self,
context: &Self::Context,
) -> Result<TransitionResult<Self::SMResult>>
fn step( &mut self, context: &Self::Context, ) -> Result<TransitionResult<Self::SMResult>>
Transition the state machine to the next state.
Returns TransitionResult::Io if the state machine needs to perform an IO operation.
Returns TransitionResult::Continue if the state machine needs to continue.
Returns TransitionResult::Done if the state machine is done.
Sourcefn finalize(&mut self, context: &Self::Context) -> Result<()>
fn finalize(&mut self, context: &Self::Context) -> Result<()>
Finalize the state machine.
This is called when the state machine is done.
Sourcefn is_finalized(&self) -> bool
fn is_finalized(&self) -> bool
Check if the state machine is finalized.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".