state_machine

Attribute Macro state_machine 

Source
#[state_machine]
Available on crate feature macro only.
Expand description

Macro for deriving the state and superstate enum.

By parsing the underlying impl block and searching for methods with the state, superstate or action attribute, the state_machine macro can derive the state and superstate enums. By default these will be given the names ‘State’ and ‘Superstate’. Next to that the macro will also implement the State trait for the state enum and the Superstate trait for the superstate enum.

To override the default configuration you can use the following attributes.

  • #[state_machine(state(name = "CustomStateName"))]

    Set the name of the state enum to a custom name.

    Default: State


  • #[state_machine(superstate(name = "CustomSuperstateName"))]

    Set the name of the superstate enum to a custom name.

    Default: Superstate


  • #[state_machine(state(derive(SomeTrait, AnotherTrait)))]

    Apply the derive macro with the passed traits to the state enum.

    Default: ()


  • #[state_machine(superstate(derive(SomeTrait, AnotherTrait)))]

    Apply the derive macro with the passed traits to the superstate enum.

    Default: ()