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

pub struct GCounter<A: Ord + Clone + Encodable + Decodable> {
    // some fields omitted
}

GCounter is a grow-only witnessed counter.

Examples

use crdts::GCounter;
let (mut a, mut b) = (GCounter::new(), GCounter::new());
a.increment("A".to_string());
b.increment("B".to_string());
assert_eq!(a.value(), b.value());
assert!(a == b);
a.increment("A".to_string());
assert!(a > b);

Methods

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

fn new() -> GCounter<A>

Produces a new GCounter.

fn increment(&mut self, actor: A)

Increments a particular actor's counter.

fn value(&self) -> u64

Returns the current sum of this counter.

fn merge(&mut self, other: GCounter<A>)

Merge another gcounter into this one, without regard to dominance.

Examples

use crdts::GCounter;
let (mut a, mut b, mut c) = (GCounter::new(), GCounter::new(), GCounter::new());
a.increment("A".to_string());
b.increment("B".to_string());
c.increment("A".to_string());
c.increment("B".to_string());
a.merge(b);
assert_eq!(a, c);

Trait Implementations

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

fn cmp(&self, other: &GCounter<A>) -> Ordering

This method returns an Ordering between self and other. Read more

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

fn partial_cmp(&self, other: &GCounter<A>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, other: &Rhs) -> bool
1.0.0

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, other: &Rhs) -> bool
1.0.0

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

fn eq(&self, other: &GCounter<A>) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.

Derived Implementations

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

fn decode<__DA: Decoder>(__arg_0: &mut __DA) -> Result<GCounter<A>, __DA::Error>

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

fn encode<__SA: Encoder>(&self, __arg_0: &mut __SA) -> Result<(), __SA::Error>

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

fn hash<__HA: Hasher>(&self, __arg_0: &mut __HA)

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

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

fn clone(&self) -> GCounter<A>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

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

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

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.