solverforge_core/domain/supply/mod.rs
1/* Supply infrastructure for variable relationship tracking.
2
3Supplies provide efficient access to derived information about planning variables,
4such as inverse relationships (who points to whom) and anchor tracking (chain roots).
5
6# Zero-Erasure Design
7
8- **Index-based**: All supplies store indices, not cloned domain objects
9- **Owned**: Supplies are owned directly, no `Arc`, `Box`, or `dyn`
10- **Mutation via `&mut`**: Standard Rust ownership, no `RwLock` or interior mutability
11- **Generic**: Full type information preserved through the entire pipeline
12
13# Available Supplies
14
15- [`InverseSupply`]: Maps values to entity indices for O(1) inverse lookups
16- [`AnchorSupply`]: Maps entity indices to anchor indices for chain tracking
17- [`ListStateSupply`]: Tracks element positions in list variables
18
19# Usage
20
21Supplies are owned by the score director or solver scope. They're created
22when needed and accessed via regular Rust references:
23
24```
25use solverforge_core::domain::supply::{InverseSupply, AnchorSupply, ListStateSupply};
26
27// Create supplies owned by your containing struct
28let mut inverse: InverseSupply<i64> = InverseSupply::new();
29let mut anchor = AnchorSupply::new();
30let mut list_state: ListStateSupply<usize> = ListStateSupply::new();
31
32// Use with standard Rust ownership
33inverse.insert(42, 0); // value 42 -> entity index 0
34anchor.set(0, 5); // entity 0 -> anchor 5
35list_state.assign(10, 0, 0); // element 10 -> entity 0, position 0
36
37// Read with shared reference
38assert_eq!(inverse.get(&42), Some(0));
39assert_eq!(anchor.get(0), Some(5));
40assert_eq!(list_state.get_entity(&10), Some(0));
41```
42*/
43
44mod anchor;
45mod inverse;
46mod list_state;
47
48#[cfg(test)]
49mod tests;
50
51pub use anchor::AnchorSupply;
52pub use inverse::InverseSupply;
53pub use list_state::{ElementPosition, ListStateSupply};