Trait crdts::CmRDT

source ·
pub trait CmRDT {
    type Op;
    type Validation: Error;

    // Required methods
    fn validate_op(&self, op: &Self::Op) -> Result<(), Self::Validation>;
    fn apply(&mut self, op: Self::Op);
}
Expand description

Operation based CRDT’s replicate by transmitting each operation.

Required Associated Types§

source

type Op

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.

  • Actor A produces ops A1, A2
  • Actor B produces ops B1, B2

the only valid orderings are:

  • A1 < A2 < B1 < B2
  • A1 < B1 < A2 < B2
  • B1 < A1 < A2 < B2
  • A1 < B1 < B2 < A2
  • B1 < A1 < B2 < A2
  • B1 < B2 < A1 < A2

Applying ops in any of the valid orders will converge to the same CRDT state

Op’s must be idempotent, meaning any Op may be applied more than once.

source

type Validation: Error

The validation error returned by validate_op.

Required Methods§

source

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.

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

source

fn apply(&mut self, op: Self::Op)

Apply an Op to the CRDT

Implementors§

source§

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

source§

impl<A: Ord + Clone + Debug> CmRDT for PNCounter<A>

§

type Op = Op<A>

§

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

source§

impl<A: Ord + Clone + Debug> CmRDT for VClock<A>

§

type Op = Dot<A>

§

type Validation = DotRange<A>

source§

impl<K: Ord, V: Val<A> + Debug, A: Ord + Hash + Clone + Debug> CmRDT for Map<K, V, A>

§

type Op = Op<K, V, A>

§

type Validation = CmRDTValidation<V, A>

source§

impl<M: Hash + Clone + Eq, A: Ord + Hash + Clone + Debug> CmRDT for Orswot<M, A>

§

type Op = Op<M, A>

§

type Validation = <VClock<A> as CmRDT>::Validation

source§

impl<T, A: Ord + Clone + Debug> CmRDT for List<T, A>

§

type Op = Op<T, A>

§

type Validation = DotRange<A>

source§

impl<T: Ord> CmRDT for GList<T>

§

type Op = Op<T>

§

type Validation = Infallible

source§

impl<T: Ord> CmRDT for GSet<T>

source§

impl<T: Sha3Hash> CmRDT for MerkleReg<T>

source§

impl<V, A: Ord> CmRDT for MVReg<V, A>

§

type Op = Op<V, A>

§

type Validation = Infallible

source§

impl<V: PartialEq, M: Ord> CmRDT for LWWReg<V, M>

§

type Op = LWWReg<V, M>

§

type Validation = Validation