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

pub struct MVReg<V, 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"]);

Implementations

impl<V, 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> where
    V: Clone
[src]

Consumes the register and returns the values

pub fn read_ctx(&self) -> ReadCtx<(), A>[src]

Retrieve the current read context

Trait Implementations

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

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

impl<V, 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, A: Actor> CvRDT for MVReg<V, A>[src]

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

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

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

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

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

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

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

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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<V, T> VZip<V> for T where
    V: MultiLane<T>, 

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