[−][src]Struct crdts::mvreg::MVReg
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]
V: Clone,
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
pub fn apply(&mut self, op: Self::Op)
[src]
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]
V: Deserialize<'de>,
A: Deserialize<'de>,
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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]
pub fn eq(&self, other: &Self) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<V, A: Actor> Serialize for MVReg<V, A> where
V: Serialize,
A: Serialize,
[src]
V: Serialize,
A: Serialize,
Auto Trait Implementations
impl<V, A> RefUnwindSafe for MVReg<V, A> where
A: RefUnwindSafe,
V: RefUnwindSafe,
A: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, A> Send for MVReg<V, A> where
A: Send,
V: Send,
A: Send,
V: Send,
impl<V, A> Sync for MVReg<V, A> where
A: Sync,
V: Sync,
A: Sync,
V: Sync,
impl<V, A> Unpin for MVReg<V, A> where
V: Unpin,
V: Unpin,
impl<V, A> UnwindSafe for MVReg<V, A> where
A: RefUnwindSafe,
V: UnwindSafe,
A: RefUnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<A, T> Val<A> for T where
A: Actor,
T: Clone + Causal<A> + CmRDT + CvRDT,
[src]
A: Actor,
T: Clone + Causal<A> + CmRDT + CvRDT,