pub struct GCounter { /* private fields */ }Expand description
A Grow-only Counter (G-Counter)
Each node maintains its own count, total is the sum of all counts. Only supports increment operations.
Implementations§
Source§impl GCounter
impl GCounter
Sourcepub fn node_count(&self, node_id: &NodeId) -> u64
pub fn node_count(&self, node_id: &NodeId) -> u64
Get the count for a specific node
Sourcepub fn merge(&mut self, other: &GCounter)
pub fn merge(&mut self, other: &GCounter)
Merge with another counter
Takes the max of each node’s count
Sourcepub fn node_count_total(&self) -> usize
pub fn node_count_total(&self) -> usize
Get the number of nodes that have contributed
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GCounter
impl RefUnwindSafe for GCounter
impl Send for GCounter
impl Sync for GCounter
impl Unpin for GCounter
impl UnwindSafe for GCounter
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