pub struct Orswot<M: Hash + Eq, A: Ord + Hash> { /* private fields */ }
Expand description
Orswot
is an add-biased or-set without tombstones ported from
the riak_dt CRDT library.
Implementations§
source§impl<M: Hash + Clone + Eq, A: Ord + Hash + Clone> Orswot<M, A>
impl<M: Hash + Clone + Eq, A: Ord + Hash + Clone> Orswot<M, A>
sourcepub fn add_all<I: IntoIterator<Item = M>>(
&self,
members: I,
ctx: AddCtx<A>
) -> Op<M, A>
pub fn add_all<I: IntoIterator<Item = M>>( &self, members: I, ctx: AddCtx<A> ) -> Op<M, A>
Add multiple elements.
sourcepub fn rm_all<I: IntoIterator<Item = M>>(
&self,
members: I,
ctx: RmCtx<A>
) -> Op<M, A>
pub fn rm_all<I: IntoIterator<Item = M>>( &self, members: I, ctx: RmCtx<A> ) -> Op<M, A>
Remove members with a witnessing ctx.
sourcepub fn iter(&self) -> impl Iterator<Item = ReadCtx<&M, A>>
pub fn iter(&self) -> impl Iterator<Item = ReadCtx<&M, A>>
Gets an iterator over the entries of the Map
.
Examples
use crdts::{Orswot, CmRDT};
let actor = "actor";
let mut set: Orswot<u8, &'static str> = Default::default();
let add_ctx = set.read_ctx().derive_add_ctx(actor);
set.apply(set.add(100, add_ctx));
let add_ctx = set.read_ctx().derive_add_ctx(actor);
set.apply(set.add(50, add_ctx));
let mut items: Vec<_> = set
.iter()
.map(|item_ctx| *item_ctx.val)
.collect();
items.sort();
assert_eq!(items, &[50, 100]);
Trait Implementations§
source§impl<M: Hash + Clone + Eq, A: Ord + Hash + Clone + Debug> CmRDT for Orswot<M, A>
impl<M: Hash + Clone + Eq, A: Ord + Hash + Clone + Debug> CmRDT for Orswot<M, A>
§type Op = Op<M, A>
type Op = Op<M, 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
§type Validation = <VClock<A> as CmRDT>::Validation
type Validation = <VClock<A> as CmRDT>::Validation
The validation error returned by
validate_op
.source§fn validate_op(&self, op: &Self::Op) -> Result<(), Self::Validation>
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. Read more
source§impl<M: Hash + Eq + Clone + Debug, A: Ord + Hash + Clone + Debug> CvRDT for Orswot<M, A>
impl<M: Hash + Eq + Clone + Debug, A: Ord + Hash + Clone + Debug> CvRDT for Orswot<M, A>
§type Validation = Validation<M, A>
type Validation = Validation<M, A>
The validation error returned by
validate_merge
.source§fn validate_merge(&self, other: &Self) -> Result<(), Self::Validation>
fn validate_merge(&self, other: &Self) -> 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 merge compatibility before attempting to merge. Read more
source§impl<'de, M, A> Deserialize<'de> for Orswot<M, A>where
M: Deserialize<'de> + Hash + Eq,
A: Deserialize<'de> + Ord + Hash,
impl<'de, M, A> Deserialize<'de> for Orswot<M, A>where M: Deserialize<'de> + Hash + Eq, A: Deserialize<'de> + Ord + Hash,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<M: PartialEq + Hash + Eq, A: PartialEq + Ord + Hash> PartialEq<Orswot<M, A>> for Orswot<M, A>
impl<M: PartialEq + Hash + Eq, A: PartialEq + Ord + Hash> PartialEq<Orswot<M, A>> for Orswot<M, A>
source§impl<M: Hash + Clone + Eq, A: Ord + Hash> ResetRemove<A> for Orswot<M, A>
impl<M: Hash + Clone + Eq, A: Ord + Hash> ResetRemove<A> for Orswot<M, A>
source§fn reset_remove(&mut self, clock: &VClock<A>)
fn reset_remove(&mut self, clock: &VClock<A>)
Remove data that is strictly smaller than this clock
source§impl<M, A> Serialize for Orswot<M, A>where
M: Serialize + Hash + Eq,
A: Serialize + Ord + Hash,
impl<M, A> Serialize for Orswot<M, A>where M: Serialize + Hash + Eq, A: Serialize + Ord + Hash,
impl<M: Eq + Hash + Eq, A: Eq + Ord + Hash> Eq for Orswot<M, A>
impl<M: Hash + Eq, A: Ord + Hash> StructuralEq for Orswot<M, A>
impl<M: Hash + Eq, A: Ord + Hash> StructuralPartialEq for Orswot<M, A>
Auto Trait Implementations§
impl<M, A> RefUnwindSafe for Orswot<M, A>where A: RefUnwindSafe, M: RefUnwindSafe,
impl<M, A> Send for Orswot<M, A>where A: Send, M: Send,
impl<M, A> Sync for Orswot<M, A>where A: Sync, M: Sync,
impl<M, A> Unpin for Orswot<M, A>where M: Unpin,
impl<M, A> UnwindSafe for Orswot<M, A>where A: RefUnwindSafe, M: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more