Macro sfsm::add_messages [−][src]
add_messages!() { /* proc-macro */ }
Expand description
Generates code to push messages into states or poll messages from states.
The messaging definition is expected too hold to the following pattern:
ⓘ
add_messages!( StateMachineName, [ Message1 <- State1, Message2 <- State1, Message1 -> State2, ... ] );
- StateMachineName: This must match a previously with add_state_machine defined state machine.
- [ Message1 <- State1, … ] Defines all messages that can be passed back an forth. The message specifies the struct/enum that will be used as a message, the <- arrow defines a poll and the -> a push and the state is the target or source state. For each message, the source/target state must implement the according ReceiveMessage or ReturnMessage trait. An example might look like this.
ⓘ
struct Liftoff {} struct Land {} struct Command<T> {} struct Status { height: float32, speed: float32} add_messages!( Rocket, [ Command<Liftoff> -> Move<Down>, Command<Land> -> Move<Up>, Status <- Move<Up> Status <- Move<Down> ] );