How states and outcomes work
mainStates are methods in your impl block decorated with #[state]. When an event is handled, the method receives the event as an argument. Every state method must return an Outcome<State>, which determines the next step in the state machine lifecycle:
Handled: The event was processed, and the machine remains in the current state.Transition(State): The machine transitions to the specified new state.Super: The event is not handled by the current state and is deferred to its parent superstate.
#[state]
fn led_on(event: &Event) -> Outcome<State> {
Transition(State::led_off())
}