#[state_machine]Expand description
Designates a module for state machine generation.
Moku expects the following items directly inside of the attributed module:
- an empty module attributed with
machine_module - exactly one implementation of
TopState - any number of implementations of
Substate
An optional name can be provided as an argument to set the default name of the
StateMachine for use in logging. If not provided, the name defaults to the
module name in UpperCamel case. This is useful for no_std environments
where StateMachine::set_name is not available.
ยงExamples
#[moku::state_machine]
mod blinky {
#[moku::machine_module]
mod machine {}
use machine::State;
struct Top;
impl moku::TopState for Top {}
struct Led;
impl moku::Substate<Top> for Led {}
}With a custom name:
#[moku::state_machine(Kikai)]
mod my_machine {
#[moku::machine_module]
pub mod machine {}
pub struct Top;
impl moku::TopState for Top {}
}
let machine = my_machine::machine::Builder::new(my_machine::Top).build();
assert_eq!(machine.name(), "Kikai");