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§
Sourcetype Evt
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§
Sourcefn init(&mut self) -> InitResult<Self>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.