[][src]Struct crdts::mvreg::MVReg

pub struct MVReg<V: Val, A: Actor> { /* fields omitted */ }

MVReg (Multi-Value Register) On concurrent writes, we will keep all values for which we can't establish a causal history.

use crdts::{CmRDT, MVReg, Dot, VClock};
let mut r1 = MVReg::new();
let mut r2 = r1.clone();
let r1_read_ctx = r1.read();
let r2_read_ctx = r2.read();

r1.apply(r1.write("bob", r1_read_ctx.derive_add_ctx(123)));

let op = r2.write("alice", r2_read_ctx.derive_add_ctx(111));
r2.apply(op.clone());

r1.apply(op); // we replicate op to r1

// Since "bob" and "alice" were added concurrently, we see both on read
assert_eq!(r1.read().val, vec!["bob", "alice"]);

Methods

impl<V: Val, A: Actor> MVReg<V, A>[src]

pub fn new() -> Self[src]

Construct a new empty MVReg

pub fn write(&self, val: V, ctx: AddCtx<A>) -> Op<V, A>[src]

Set the value of the register

pub fn read(&self) -> ReadCtx<Vec<V>, A>[src]

Consumes the register and returns the values

Trait Implementations

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

impl<V: Val, A: Actor> CmRDT for MVReg<V, A>[src]

type Op = Op<V, 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

impl<V: Val, A: Actor> Causal<A> for MVReg<V, A>[src]

impl<V: Val + PartialEq, A: Actor> PartialEq<MVReg<V, A>> for MVReg<V, A>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<V: Val + Eq, A: Actor> Eq for MVReg<V, A>[src]

impl<V: Val, A: Actor> Default for MVReg<V, A>[src]

impl<V: Clone + Val, A: Clone + Actor> Clone for MVReg<V, A>[src]

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

Performs copy-assignment from source. Read more

impl<V: Debug + Val, A: Debug + Actor> Debug for MVReg<V, A>[src]

impl<V: Val + Display, A: Actor + Display> Display for MVReg<V, A>[src]

impl<V: Val, A: Actor> Serialize for MVReg<V, A> where
    V: Serialize,
    A: Serialize
[src]

impl<'de, V: Val, A: Actor> Deserialize<'de> for MVReg<V, A> where
    V: Deserialize<'de>,
    A: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<V, A> Send for MVReg<V, A> where
    A: Send,
    V: Send

impl<V, A> Unpin for MVReg<V, A> where
    A: Unpin,
    V: Unpin

impl<V, A> Sync for MVReg<V, A> where
    A: Sync,
    V: Sync

impl<V, A> UnwindSafe for MVReg<V, A> where
    A: RefUnwindSafe + UnwindSafe,
    V: UnwindSafe

impl<V, A> RefUnwindSafe for MVReg<V, A> where
    A: RefUnwindSafe,
    V: RefUnwindSafe

Blanket Implementations

impl<T> Val for T where
    T: PartialEq<T> + Clone + Debug
[src]

impl<T> Val for T where
    T: Clone + Debug
[src]

impl<A, T> Val<A> for T where
    A: Actor,
    T: Debug + Default + Clone + Causal<A> + CmRDT + CvRDT
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

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