pub struct GCounter<A: Ord> { /* private fields */ }
Expand description
GCounter
is a grow-only witnessed counter.
Examples
use crdts::{GCounter, CmRDT};
let mut a = GCounter::new();
let mut b = GCounter::new();
a.apply(a.inc("A"));
b.apply(b.inc("B"));
assert_eq!(a.read(), b.read());
a.apply(a.inc("A"));
assert!(a.read() > b.read());
Implementations§
Trait Implementations§
source§impl<A: Ord + Clone + Debug> CmRDT for GCounter<A>
impl<A: Ord + Clone + Debug> CmRDT for GCounter<A>
§type Op = Dot<A>
type Op = Dot<A>
Op defines a mutation to the CRDT.
As long as Op’s from one actor are replayed in exactly the same order they
were generated by that actor, the CRDT will converge. In other words, we must
have a total ordering on each actors operations, while requiring only a partial
order over all ops.
E.g. Read more
§type Validation = Infallible
type Validation = Infallible
The validation error returned by
validate_op
.source§fn validate_op(&self, _op: &Self::Op) -> Result<(), Self::Validation>
fn validate_op(&self, _op: &Self::Op) -> Result<(), Self::Validation>
Some CRDT’s have stricter requirements on how they must be used.
To avoid violating these requirements, CRDT’s provide an interface
to optionally validate op’s before they are applied. Read more
source§impl<A: Ord + Clone + Debug> CvRDT for GCounter<A>
impl<A: Ord + Clone + Debug> CvRDT for GCounter<A>
§type Validation = Infallible
type Validation = Infallible
The validation error returned by
validate_merge
.source§fn validate_merge(&self, _other: &Self) -> Result<(), Self::Validation>
fn validate_merge(&self, _other: &Self) -> Result<(), Self::Validation>
Some CRDT’s have stricter requirements on how they must be used.
To avoid violating these requirements, CRDT’s provide an interface
to optionally validate merge compatibility before attempting to merge. Read more
source§impl<'de, A> Deserialize<'de> for GCounter<A>where
A: Deserialize<'de> + Ord,
impl<'de, A> Deserialize<'de> for GCounter<A>where A: Deserialize<'de> + Ord,
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<A: PartialEq + Ord> PartialEq<GCounter<A>> for GCounter<A>
impl<A: PartialEq + Ord> PartialEq<GCounter<A>> for GCounter<A>
source§impl<A: Ord> ResetRemove<A> for GCounter<A>
impl<A: Ord> ResetRemove<A> for GCounter<A>
source§fn reset_remove(&mut self, clock: &VClock<A>)
fn reset_remove(&mut self, clock: &VClock<A>)
Remove data that is strictly smaller than this clock
impl<A: Eq + Ord> Eq for GCounter<A>
impl<A: Ord> StructuralEq for GCounter<A>
impl<A: Ord> StructuralPartialEq for GCounter<A>
Auto Trait Implementations§
impl<A> RefUnwindSafe for GCounter<A>where A: RefUnwindSafe,
impl<A> Send for GCounter<A>where A: Send,
impl<A> Sync for GCounter<A>where A: Sync,
impl<A> Unpin for GCounter<A>
impl<A> UnwindSafe for GCounter<A>where A: RefUnwindSafe,
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