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§
Source§impl DeltaCrdt for GCounter
impl DeltaCrdt for GCounter
Source§type Delta = GCounterDelta
type Delta = GCounterDelta
The type of delta produced by this CRDT.
Source§fn delta(&self, other: &Self) -> GCounterDelta
fn delta(&self, other: &Self) -> GCounterDelta
Source§fn apply_delta(&mut self, delta: &GCounterDelta)
fn apply_delta(&mut self, delta: &GCounterDelta)
Apply a delta to this replica’s state. Read more
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