[−][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"]);
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
fn apply(&mut self, op: Self::Op)
[src]
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]
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.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(&self) -> 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]
V: Serialize,
A: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de, V: Val, A: Actor> Deserialize<'de> for MVReg<V, A> where
V: Deserialize<'de>,
A: Deserialize<'de>,
[src]
V: Deserialize<'de>,
A: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl<V, A> Send for MVReg<V, A> where
A: Send,
V: Send,
A: Send,
V: Send,
impl<V, A> Unpin for MVReg<V, A> where
A: Unpin,
V: Unpin,
A: Unpin,
V: Unpin,
impl<V, A> Sync for MVReg<V, A> where
A: Sync,
V: Sync,
A: Sync,
V: Sync,
impl<V, A> UnwindSafe for MVReg<V, A> where
A: RefUnwindSafe + UnwindSafe,
V: UnwindSafe,
A: RefUnwindSafe + UnwindSafe,
V: UnwindSafe,
impl<V, A> RefUnwindSafe for MVReg<V, A> where
A: RefUnwindSafe,
V: RefUnwindSafe,
A: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Val for T where
T: PartialEq<T> + Clone + Debug,
[src]
T: PartialEq<T> + Clone + Debug,
impl<T> Val for T where
T: Clone + Debug,
[src]
T: Clone + Debug,
impl<A, T> Val<A> for T where
A: Actor,
T: Debug + Default + Clone + Causal<A> + CmRDT + CvRDT,
[src]
A: Actor,
T: Debug + Default + Clone + Causal<A> + CmRDT + CvRDT,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,