#[derive(StateMachine)]
{
// Attributes available to this derive:
#[state_machine]
#[only_accepts]
}
Expand description
Derive StateMachine for an enum of states.
ⓘ
#[derive(StateMachine, Clone, Debug, PartialEq)]
#[state_machine(initial = Draft, terminal = [Published, Archived])]
enum Article { Draft, Review, Published, Archived }§Data-carrying fields must implement Default
analyze! and test! walk every state variant, and the derive builds one
representative per variant to walk. Analysis is variant-level, so any
data-carrying fields are filled with Default::default() — the payload types
must therefore implement Default, or you can hand-write the StateMachine impl.
Fieldless enums (including the aggregate tier’s phase machines) need nothing
extra.