ferogram-derive
Procedural macros for the ferogram workspace. Currently exposes #[derive(FsmState)].
Most users get this through ferogram with the derive feature flag. Direct usage is only needed when building on top of the FSM layer directly.
Installation
Via the ferogram crate (recommended):
[]
= { = "0.3.8", = ["derive"] }
Or directly:
[]
= "0.3.8"
#[derive(FsmState)]
Implements the ferogram::fsm::FsmState trait for an enum.
Restrictions: only unit variants are supported. Tuple or struct variants produce a compile error.
What gets generated:
as_key(&self) -> Stringconverts the variant name to a string.from_key(key: &str) -> Option<Self>parses the variant name back into the enum.
use FsmState;
The generated impl:
Keys are the variant names as written in source. Renaming a variant changes its key and breaks any stored state.
Using FsmState in a dispatcher
use ;
use Arc;
dp.with_state_storage;
dp.on_message_fsm;
dp.on_message_fsm;
Stack position
ferogram
└ ferogram-derive <-- here (proc-macro crate, compile-time only)
License
MIT or Apache-2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.
Ankit Chaubey - github.com/ankit-chaubey