#[machine]Expand description
Define a typed machine that carries durable context across states.
The machine must be a struct whose first generic parameter is the
#[state] enum family:
struct Task<TaskState> { ... }struct Payment<PaymentState> { ... }
#[machine] generates:
- the typed
Machine<State>surface - a builder for new machines
- a machine-scoped
machine::Stateenum for matching rebuilt machines - a machine-scoped
machine::Fieldsstruct for heterogeneous batch rebuilds
If you need derives, place them below #[machine].
use statum::{machine, state};
#[state]
enum TaskState {
Draft,
Published,
}
#[machine]
struct Task<TaskState> {
id: u64,
}
fn main() {
let task = Task::<Draft>::builder().id(1).build();
assert_eq!(task.id, 1);
}Define a typed machine that carries durable context across states.
Apply #[machine] to a struct whose first generic parameter is the
#[state] enum family. Statum generates the typed machine surface, builders,
the machine-scoped machine::State enum, and helper items such as
machine::Fields for heterogeneous batch rebuilds.