Juncture Derive
Proc-macro derive implementation for the Juncture State trait. This crate provides #[derive(State)] which generates typed State/Update pairs with per-field reducer semantics.
Generated Code
For a struct like:
The macro generates:
MyStateUpdate- Update struct with all fields asOption<T>- Field index constants -
MyState::FIELD_MESSAGES: usize = 0, etc. Statetrait impl -apply()with per-field reducer dispatch
Reducer Types
| Reducer | Behavior |
|---|---|
replace |
Default. Single writer per superstep |
append |
Vec extend |
ephemeral |
Reset to Default after each superstep |
last_write_wins |
Multiple writers, last wins |
untracked |
Not persisted across checkpoints |
replace_after_finish |
Available only after finish() call |
any |
All writers should provide equal values |
custom = path::to::func |
Custom merge function |
Container Attributes
#[state_version(N)]- Set schema version (default 1)#[migrate_from(N, path::to::func)]- Migration from version N#[subset_of(ParentState)]- GenerateStateSubset<ParentState>impl
Constraints
- Structs must have named fields (no tuple or unit structs)
- Maximum 64 fields (u64 bitmask limit)
- Only one derive per struct
License
Licensed under Apache License, Version 2.0. See LICENSE for details.