macro_rules! define_state_machine {
(
name: $name:ident,
states: { $($state:ident),* $(,)? },
inputs: { $($input:ident),* $(,)? },
initial: $initial:ident,
transitions: {
$(
$from:ident + $inp:ident => $to:ident
),* $(,)?
}
) => { ... };
}
Expand description
Macro for defining deterministic state machines - non-serde version
This macro is used to quickly define deterministic state machines where each state+input combination can have at most one next state.
§Syntax
use yasm::define_state_machine;
define_state_machine! {
name: MyStateMachine,
states: { State1, State2, State3 },
inputs: { Input1, Input2 },
initial: State1,
transitions: {
State1 + Input1 => State2,
State2 + Input2 => State3,
}
}
§Parameters
name
: Name of the state machine structstates
: List of all possible statesinputs
: List of all possible inputsinitial
: Initial statetransitions
: State transition rules in the formatfrom_state + input => to_state