pub struct GCounter { /* private fields */ }Expand description
A grow-only counter (G-Counter).
Each replica maintains its own count. The total value is the sum of all replica counts. This counter can only be incremented, never decremented.
§Example
use crdt_kit::prelude::*;
let mut c1 = GCounter::new("node-1");
c1.increment();
c1.increment();
let mut c2 = GCounter::new("node-2");
c2.increment();
c1.merge(&c2);
assert_eq!(c1.value(), 3);Implementations§
Trait Implementations§
impl Eq for GCounter
impl StructuralPartialEq for GCounter
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