pub struct ORSet<T: Ord + Clone> { /* private fields */ }Expand description
An observed-remove set (OR-Set), also known as an add-wins set.
Unlike the 2P-Set, elements can be freely added and removed, and re-added after removal. Each add operation generates a unique tag. Remove only removes the tags that the remover has observed, so concurrent adds are preserved.
§Example
use crdt_kit::prelude::*;
let mut s1 = ORSet::new("node-1");
s1.insert("apple");
s1.insert("banana");
s1.remove(&"banana");
let mut s2 = ORSet::new("node-2");
s2.insert("banana"); // concurrent add
s1.merge(&s2);
// banana is present because s2's add was concurrent with s1's remove
assert!(s1.contains(&"banana"));
assert!(s1.contains(&"apple"));Implementations§
Source§impl<T: Ord + Clone> ORSet<T>
impl<T: Ord + Clone> ORSet<T>
Sourcepub fn insert(&mut self, value: T)
pub fn insert(&mut self, value: T)
Insert an element into the set.
Generates a unique tag for this insertion. Even if the element was previously removed, this new tag allows it to be re-added.
Trait Implementations§
impl<T: Eq + Ord + Clone> Eq for ORSet<T>
impl<T: Ord + Clone> StructuralPartialEq for ORSet<T>
Auto Trait Implementations§
impl<T> Freeze for ORSet<T>
impl<T> RefUnwindSafe for ORSet<T>where
T: RefUnwindSafe,
impl<T> Send for ORSet<T>where
T: Send,
impl<T> Sync for ORSet<T>where
T: Sync,
impl<T> Unpin for ORSet<T>
impl<T> UnwindSafe for ORSet<T>where
T: RefUnwindSafe,
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