pub struct ConstraintState {
pub node_id: String,
pub constraints: ConstraintORSet,
pub metrics: ConstraintGCounter,
pub position: EisensteinRegister,
pub version: u64,
}Expand description
The complete constraint state of a fleet node, mergeable without coordination.
This is the key data structure: each node maintains one ConstraintState,
and periodically merges with other nodes. The result is always consistent.
Fields§
§node_id: StringNode identifier
constraints: ConstraintORSetActive constraints (OR-Set)
metrics: ConstraintGCounterAggregate metrics (G-Counter)
position: EisensteinRegisterCurrent position in constraint space
version: u64State version (increments on each local mutation)
Implementations§
Source§impl ConstraintState
impl ConstraintState
pub fn new(node_id: &str) -> Self
Sourcepub fn add_constraint(&mut self, id: &str)
pub fn add_constraint(&mut self, id: &str)
Add a constraint
Sourcepub fn remove_constraint(&mut self, id: &str)
pub fn remove_constraint(&mut self, id: &str)
Remove a constraint
Sourcepub fn record_satisfied(&mut self, count: u64)
pub fn record_satisfied(&mut self, count: u64)
Record satisfied constraints
Sourcepub fn record_violations(&mut self, count: u64)
pub fn record_violations(&mut self, count: u64)
Record violations
Sourcepub fn update_position(&mut self, pos: (i32, i32))
pub fn update_position(&mut self, pos: (i32, i32))
Update lattice position
Sourcepub fn satisfaction_rate(&self) -> f64
pub fn satisfaction_rate(&self) -> f64
Satisfaction rate (0.0 - 1.0)
Sourcepub fn active_constraint_count(&self) -> usize
pub fn active_constraint_count(&self) -> usize
Number of active constraints
Trait Implementations§
Source§impl Clone for ConstraintState
impl Clone for ConstraintState
Source§fn clone(&self) -> ConstraintState
fn clone(&self) -> ConstraintState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConstraintState
impl Debug for ConstraintState
Source§impl<'de> Deserialize<'de> for ConstraintState
impl<'de> Deserialize<'de> for ConstraintState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ConstraintState
impl Display for ConstraintState
Source§impl Merge for ConstraintState
impl Merge for ConstraintState
Source§impl PartialEq for ConstraintState
impl PartialEq for ConstraintState
Auto Trait Implementations§
impl Freeze for ConstraintState
impl RefUnwindSafe for ConstraintState
impl Send for ConstraintState
impl Sync for ConstraintState
impl Unpin for ConstraintState
impl UnsafeUnpin for ConstraintState
impl UnwindSafe for ConstraintState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more