pub trait CellStateExt {
Show 18 methods
// Required methods
fn new(config: CellConfig) -> Self;
fn update_timestamp(&mut self);
fn is_full(&self) -> bool;
fn is_valid(&self) -> bool;
fn add_member(&mut self, node_id: String) -> bool;
fn remove_member(&mut self, node_id: &str) -> bool;
fn set_leader(&mut self, node_id: String) -> Result<(), &'static str>;
fn clear_leader(&mut self);
fn add_capability(&mut self, capability: Capability);
fn get_capabilities_by_type(
&self,
capability_type: CapabilityType,
) -> Vec<&Capability>;
fn has_capability_type(&self, capability_type: CapabilityType) -> bool;
fn assign_platoon(&mut self, platoon_id: String);
fn leave_platoon(&mut self);
fn merge(&mut self, other: &CellState);
fn member_count(&self) -> usize;
fn is_member(&self, node_id: &str) -> bool;
fn is_leader(&self, node_id: &str) -> bool;
fn get_id(&self) -> Option<&str>;
}Required Methods§
Sourcefn new(config: CellConfig) -> Self
fn new(config: CellConfig) -> Self
Create a new cell state
Sourcefn update_timestamp(&mut self)
fn update_timestamp(&mut self)
Update the timestamp to current time
Sourcefn add_member(&mut self, node_id: String) -> bool
fn add_member(&mut self, node_id: String) -> bool
Add a member to the cell (OR-Set add operation)
This implements an OR-Set CRDT where members can be added and removed. Concurrent add/remove operations are resolved by: Add wins over Remove.
Sourcefn remove_member(&mut self, node_id: &str) -> bool
fn remove_member(&mut self, node_id: &str) -> bool
Remove a member from the cell (OR-Set remove operation)
Sourcefn set_leader(&mut self, node_id: String) -> Result<(), &'static str>
fn set_leader(&mut self, node_id: String) -> Result<(), &'static str>
Set the cell leader (LWW-Register operation)
This implements Last-Write-Wins semantics for leader election. The leader must be a current member of the cell.
Sourcefn clear_leader(&mut self)
fn clear_leader(&mut self)
Clear the cell leader
Sourcefn add_capability(&mut self, capability: Capability)
fn add_capability(&mut self, capability: Capability)
Add a capability to the cell (G-Set operation)
This implements a G-Set CRDT where capabilities can only be added. Capabilities are aggregated from all cell members.
Sourcefn get_capabilities_by_type(
&self,
capability_type: CapabilityType,
) -> Vec<&Capability>
fn get_capabilities_by_type( &self, capability_type: CapabilityType, ) -> Vec<&Capability>
Get all capabilities of a specific type
Sourcefn has_capability_type(&self, capability_type: CapabilityType) -> bool
fn has_capability_type(&self, capability_type: CapabilityType) -> bool
Check if cell has a specific capability type
Sourcefn assign_platoon(&mut self, platoon_id: String)
fn assign_platoon(&mut self, platoon_id: String)
Assign cell to a platoon (LWW-Register operation)
Sourcefn leave_platoon(&mut self)
fn leave_platoon(&mut self)
Remove cell from platoon
Sourcefn merge(&mut self, other: &CellState)
fn merge(&mut self, other: &CellState)
Merge with another cell state (CRDT merge)
Merges two cell states using CRDT semantics:
- Members: Union (OR-Set merge)
- Leader: Take newer timestamp (LWW-Register merge)
- Capabilities: Union (G-Set merge)
Sourcefn member_count(&self) -> usize
fn member_count(&self) -> usize
Get the count of members
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.