#[type_state]Expand description
Turns your struct into type-state compatible version.
Usage: #[type_state(states = (State1, State2, ...), slots = (DefaultState, ...))]
Arguments:
states-> A list of the states that the struct can transition through, which will be generated as marker structs and traits.slots-> Specifies the default states for the struct’s state slots. Each slot corresponds to a tracked state.
What it does:
- Defines the valid states that a struct can transition between using the
statesattribute, - Configures multiple state slots if needed, allowing a struct to track multiple states concurrently,
- Protects against invalid struct initialization by sealing state transitions using traits and marker structs,
- Seals the trait implementations for each state to ensure safety and prevent external modification.