Trait kaori_hsm::TopState

source ·
pub trait TopState {
    type Evt;

    // Required method
    fn init(&mut self) -> InitResult<Self>;
}
Expand description

Define the initial pseudostate and the type of event variant the state machine can receive.

§Example

 enum BasicEvt{
 A,
 B,
 C
 }

 impl TopState for BasicStateMachine{
   type Evt = BasicEvt;

   fn init(&mut self) -> InitResult<Self> {
     println!("TOP_INIT");
     init_transition!(S0)  
   }
 }

Required Associated Types§

source

type Evt

Type that must be defined as an enum by the user in order to define the events which can be handled by the state machine. The State<tag>::handle() and the StateMachine::dispatch() methods of the state machine accept the type Evt as argument.

Required Methods§

source

fn init(&mut self) -> InitResult<Self>

First user code to execute during the lifetime of the state machine. Executing only once, this method allows the user to execute some custom code before returning the first state to which the state machine will transition. This method execution is triggered by the call to InitStateMachine::init().

§Implementation policy

The user must implement this method and return a state which has the top state as its parent.

Object Safety§

This trait is not object safe.

Implementors§