Struct crdts::gcounter::GCounter[][src]

pub struct GCounter<A: Ord> { /* fields omitted */ }

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

impl<A: Ord + Clone> GCounter<A>[src]

pub fn new() -> Self[src]

Produce a new GCounter.

pub fn inc(&self, actor: A) -> Dot<A>[src]

Generate Op to increment the counter.

pub fn inc_many(&self, actor: A, steps: u64) -> Dot<A>[src]

Generate Op to increment the counter by a number of steps.

pub fn read(&self) -> BigUint[src]

Return the current sum of this counter.

Trait Implementations

impl<A: Clone + Ord> Clone for GCounter<A>[src]

impl<A: Ord + Clone + Debug> CmRDT for GCounter<A>[src]

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

The validation error returned by validate_op.

impl<A: Ord + Clone + Debug> CvRDT for GCounter<A>[src]

type Validation = Infallible

The validation error returned by validate_merge.

impl<A: Debug + Ord> Debug for GCounter<A>[src]

impl<A: Ord> Default for GCounter<A>[src]

impl<'de, A: Ord> Deserialize<'de> for GCounter<A> where
    A: Deserialize<'de>, 
[src]

impl<A: Eq + Ord> Eq for GCounter<A>[src]

impl<A: Hash + Ord> Hash for GCounter<A>[src]

impl<A: PartialEq + Ord> PartialEq<GCounter<A>> for GCounter<A>[src]

impl<A: Ord> ResetRemove<A> for GCounter<A>[src]

impl<A: Ord> Serialize for GCounter<A> where
    A: Serialize
[src]

impl<A: Ord> StructuralEq for GCounter<A>[src]

impl<A: Ord> StructuralPartialEq for GCounter<A>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<A, T> Val<A> for T where
    A: Ord,
    T: Clone + Default + ResetRemove<A> + CmRDT
[src]