Skip to main content

StateTransition

Trait StateTransition 

Source
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§

Source

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.

Source

fn finalize(&mut self, context: &Self::Context) -> Result<()>

Finalize the state machine.

This is called when the state machine is done.

Source

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

Implementations on Foreign Types§

Source§

impl<State: StateTransition> StateTransition for Box<State>

Source§

type Context = <State as StateTransition>::Context

Source§

type SMResult = <State as StateTransition>::SMResult

Source§

fn step( &mut self, context: &Self::Context, ) -> Result<TransitionResult<Self::SMResult>>

Source§

fn finalize(&mut self, context: &Self::Context) -> Result<()>

Source§

fn is_finalized(&self) -> bool

Implementors§