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

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.

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.

If desired, the state machine can be stopped. When doing so, the internal states enum is returned.

Peek the internal states enum.

Implementors