solverforge_core/domain/supply/mod.rs
1//! Supply infrastructure for variable relationship tracking.
2//!
3//! Supplies provide efficient access to derived information about planning variables,
4//! such 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//!
21//! Supplies are owned by the score director or solver scope. They're created
22//! when needed and accessed via regular Rust references:
23//!
24//! ```
25//! use solverforge_core::domain::supply::{InverseSupply, AnchorSupply, ListStateSupply};
26//!
27//! // Create supplies owned by your containing struct
28//! let mut inverse: InverseSupply<i64> = InverseSupply::new();
29//! let mut anchor = AnchorSupply::new();
30//! let mut list_state: ListStateSupply<usize> = ListStateSupply::new();
31//!
32//! // Use with standard Rust ownership
33//! inverse.insert(42, 0); // value 42 -> entity index 0
34//! anchor.set(0, 5); // entity 0 -> anchor 5
35//! list_state.assign(10, 0, 0); // element 10 -> entity 0, position 0
36//!
37//! // Read with shared reference
38//! assert_eq!(inverse.get(&42), Some(0));
39//! assert_eq!(anchor.get(0), Some(5));
40//! assert_eq!(list_state.get_entity(&10), Some(0));
41//! ```
42
43mod anchor;
44mod inverse;
45mod list_state;
46
47pub use anchor::AnchorSupply;
48pub use inverse::InverseSupply;
49pub use list_state::{ElementPosition, ListStateSupply};