add_fallible_state_machine!() { /* proc-macro */ }Expand description
Generates a fallible state machine from a given state machine definition with error handling.
The state machine definition is expected too hold to the following pattern:
ⓘ
add_fallible_state_machine!(
StateMachineName,
InitialState,
[State1, State2, StateN, ...],
[StateN => StateN, ...],
ErrorType,
ErrorState
);- StateMachineName: Defines the name of the state machine.
- InitialState: The initial state the state machine will start with.
- [State1, State2, StateN, …]: Specifies all state structs that will be known to the state machine. Each state must implement the
Statetrait. - [StateN => StateN, …]: Defines all transitions between states that can occur. For each transition, the state must implement the according
Transitiontrait. - ErrorType: Defines the type of error that can be returned from the states.
- ErrorState: Defines the state that will act as the error handle state. It must implement the
TryErrorStatetrait. Adding it to the state definitions is optional.
add_fallible_state_machine!(
Rocket,
WaitForLaunch,
[WaitForLaunch, Ascent, HandleMalfunction],
[
WaitForLaunch => Ascent,
HandleMalfunction => WaitForLaunch
],
RocketMalfunction,
HandleMalfunction
);Expand the example to see more, or check out the examples folder for a more complete example.