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

pub struct GCounter<A: Ord + Clone + Encodable + Decodable> { /* 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]

Produces a new GCounter.

Increments a particular actor's counter.

Returns the current sum of this counter.

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: Debug + Ord + Clone + Encodable + Decodable> Debug for GCounter<A>
[src]

Formats the value using the given formatter.

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

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

Serialize a value using an Encoder.

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

Deserialize a value using a Decoder.

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

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

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

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

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

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

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

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]

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

This method tests for !=.