Skip to main content

OrSet

Struct OrSet 

Source
pub struct OrSet<T: Hash + Eq> {
    pub elements: HashSet<(T, Timestamp)>,
    pub tombstone: HashSet<(T, Timestamp)>,
}
Expand description

Observed-Remove Set (Add-Wins)

Fields§

§elements: HashSet<(T, Timestamp)>§tombstone: HashSet<(T, Timestamp)>

Implementations§

Source§

impl<T: Hash + Eq + Clone> OrSet<T>

Source

pub fn new() -> Self

Create a new empty OR-Set.

Source

pub fn add(&mut self, value: T, tag: Timestamp)

Add an element to the set with a unique tag.

The tag (timestamp) must be unique across all operations to ensure correct causality tracking. In bones, this is guaranteed by the event hash or ITC stamp.

Source

pub fn remove(&mut self, value: &T) -> Vec<Timestamp>
where T: Eq + Hash,

Remove an element from the set.

This tombstones all currently-observed tags for the given element. Any tags added concurrently (not yet observed) will survive, implementing add-wins semantics.

Returns the tags that were tombstoned (empty if element was not present).

Source

pub fn remove_specific(&mut self, value: &T, tags: &[Timestamp])
where T: Eq + Hash,

Remove specific tags for an element.

Tombstones only the provided tags.

Source

pub fn contains(&self, value: &T) -> bool

Check if an element is present in the set.

An element is present if it has at least one add-tag that is not covered by a corresponding tombstone.

Source

pub fn values(&self) -> HashSet<&T>

Return all currently-present values in the set.

An element is present if it has at least one un-tombstoned add-tag.

Source

pub fn len(&self) -> usize

Return the number of distinct present values.

Source

pub fn is_empty(&self) -> bool

Return true if no values are present.

Source

pub fn active_tags(&self, value: &T) -> Vec<&Timestamp>

Return all active (un-tombstoned) tags for a given value.

Source

pub fn apply(&mut self, op: OrSetOp<T>)

Apply an operation to the OR-Set.

Trait Implementations§

Source§

impl<T: Clone + Hash + Eq> Clone for OrSet<T>

Source§

fn clone(&self) -> OrSet<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Hash + Eq> Debug for OrSet<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Hash + Eq + Clone> Default for OrSet<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for OrSet<T>
where T: Deserialize<'de> + Hash + Eq,

Source§

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<T: Eq + Hash + Clone> Merge for OrSet<T>

Merge implementation for OR-Set.

The merge is a union of both the element sets and the tombstone sets. This satisfies semilattice laws because set union is commutative, associative, and idempotent.

After merge, an element is present iff it has at least one add-tag not covered by a tombstone entry.

Source§

fn merge(&mut self, other: Self)

Source§

impl<T: PartialEq + Hash + Eq> PartialEq for OrSet<T>

Source§

fn eq(&self, other: &OrSet<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for OrSet<T>
where T: Serialize + Hash + Eq,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Eq + Hash + Eq> Eq for OrSet<T>

Source§

impl<T: Hash + Eq> 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>
where T: Unpin,

§

impl<T> UnsafeUnpin for OrSet<T>

§

impl<T> UnwindSafe for OrSet<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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