Skip to main content

FsmState

Derive Macro FsmState 

Source
#[derive(FsmState)]
Expand description

Derive the [ferogram::fsm::FsmState] trait for an enum.

Only unit variants (no fields) are supported. Tuple or struct variants are rejected with a compile error.

§What gets generated

  • as_key(&self) -> String - returns the variant name as a &'static str-backed String.
  • from_key(key: &str) -> Option<Self> - parses the variant name back into the enum.

§Example

use ferogram::FsmState;

#[derive(FsmState, Clone, Debug, PartialEq)]
enum RegistrationState {
    Start,
    WaitingName,
    WaitingPhone,
    WaitingCity,
    Done,
}