Trait crdts::CvRDT[][src]

pub trait CvRDT {
    type Validation: Error;
    fn validate_merge(&self, other: &Self) -> Result<(), Self::Validation>;
fn merge(&mut self, other: Self); }

State based CRDT’s replicate by transmitting the entire CRDT state.

Associated Types

type Validation: Error[src]

The validation error returned by validate_merge.

Loading content...

Required methods

fn validate_merge(&self, other: &Self) -> Result<(), Self::Validation>[src]

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.

An Ok(()) response signals that the merge is safe to proceed. Otherwise a structured error is returned to help you determine what is wrong with the merge.

fn merge(&mut self, other: Self)[src]

Merge the given CRDT into the current CRDT.

Loading content...

Implementors

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

type Validation = Infallible

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

type Validation = <GCounter<A> as CvRDT>::Validation

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

type Validation = Infallible

impl<K: Ord + Clone + Debug, V: Val<A> + CvRDT + Debug, A: Ord + Hash + Clone + Debug> CvRDT for Map<K, V, A>[src]

type Validation = CvRDTValidation<K, V, A>

impl<M: Hash + Eq + Clone + Debug, A: Ord + Hash + Clone + Debug> CvRDT for Orswot<M, A>[src]

type Validation = Validation<M, A>

fn merge(&mut self, other: Self)[src]

Merge combines another Orswot with this one.

impl<T: Ord> CvRDT for GList<T>[src]

type Validation = Infallible

impl<T: Ord> CvRDT for GSet<T>[src]

type Validation = Infallible

fn merge(&mut self, other: Self)[src]

Merges another GSet into this one.

Examples

use crdts::{GSet, CvRDT, CmRDT};
let (mut a, mut b) = (GSet::new(), GSet::new());
a.insert(1);
b.insert(2);
a.merge(b);
assert!(a.contains(&1));
assert!(a.contains(&2));

impl<T: Sha3Hash> CvRDT for MerkleReg<T>[src]

type Validation = Infallible

impl<V, A: Ord> CvRDT for MVReg<V, A>[src]

type Validation = Infallible

impl<V: PartialEq, M: Ord> CvRDT for LWWReg<V, M>[src]

type Validation = Validation

fn validate_merge(&self, other: &Self) -> Result<(), Self::Validation>[src]

Validates whether a merge is safe to perfom

Returns an error if the marker is identical but the contained element is different.

use crdts::{lwwreg, LWWReg, CvRDT};
let mut l1 = LWWReg { val: 1, marker: 2 };
let l2 = LWWReg { val: 3, marker: 2 };
// errors!
assert_eq!(l1.validate_merge(&l2), Err(lwwreg::Validation::ConflictingMarker));

fn merge(&mut self, _: Self)[src]

Combines two LWWReg instances according to the marker that tracks causality.

Loading content...