Trait sfsm::StateMachine
source · [−]pub trait StateMachine {
type InitialState;
type Error;
type StatesEnum;
fn start(&mut self, state: Self::InitialState) -> Result<(), Self::Error>;
fn step(&mut self) -> Result<(), Self::Error>;
fn stop(self) -> Result<Self::StatesEnum, Self::Error>;
fn peek_state(&self) -> &Self::StatesEnum;
}
Expand description
Trait that will be implemented for the state machine.
Required Associated Types
type InitialState
type InitialState
The initial state of the state machine.
The returned error. This is also implemented in non fallible state machines, but will be ignore as there is no case this error could occur.
type StatesEnum
type StatesEnum
The generator enum containing all states
Required Methods
Start function that must be called first. It populates the internal enum with the initial state. If step is called before start, the state machine will return an error.
The step function that executes all states and transitions.
fn stop(self) -> Result<Self::StatesEnum, Self::Error>
fn stop(self) -> Result<Self::StatesEnum, Self::Error>
If desired, the state machine can be stopped. When doing so, the internal states enum is returned.
fn peek_state(&self) -> &Self::StatesEnum
fn peek_state(&self) -> &Self::StatesEnum
Peek the internal states enum.