ORMap

Struct ORMap 

Source
pub struct ORMap<K: Ord, V: Lattice> { /* private fields */ }
Expand description

An observed-remove map (OR-Map) with put-wins semantics and recursive value merge.

Each key maps to an [Entry] containing a value V: Lattice and an insertion timestamp. Removals record a tombstone timestamp. A key is considered present when its entry timestamp is greater than or equal to its tombstone timestamp (put-wins: concurrent put and remove resolve in favor of put).

When both replicas have a present entry for the same key, the values are merged using the V::merge lattice operation, providing recursive conflict resolution.

The internal clock advances automatically on mutation and is bumped to max(self, other) on merge.

Implementations§

Source§

impl<K: Ord, V: Lattice> ORMap<K, V>

Source

pub fn new() -> Self

Create an empty OR-Map.

Source

pub fn put(&mut self, key: K, value: V)

Put a key-value pair. Overwrites any existing value for the key.

Source

pub fn remove(&mut self, key: &K)
where K: Clone,

Remove a key by recording a tombstone at the current clock.

Source

pub fn get(&self, key: &K) -> Option<&V>

Returns a reference to the value for the key, if present.

Source

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

Returns true if the key is present.

Source

pub fn keys(&self) -> Vec<&K>

Returns a sorted vector of references to all present keys.

Source

pub fn entries(&self) -> Vec<(&K, &V)>

Returns a sorted vector of (key, value) pairs for all present entries.

Source

pub fn len(&self) -> usize

Returns the number of present entries.

Source

pub fn is_empty(&self) -> bool

Returns true if no entries are present.

Trait Implementations§

Source§

impl<K: Clone + Ord, V: Clone + Lattice> Clone for ORMap<K, V>

Source§

fn clone(&self) -> ORMap<K, V>

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<K: Debug + Ord, V: Debug + Lattice> Debug for ORMap<K, V>

Source§

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

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

impl<K: Ord, V: Lattice> Default for ORMap<K, V>

Source§

fn default() -> Self

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

impl<'de, K, V> Deserialize<'de> for ORMap<K, V>

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<K: Ord + Clone + PartialEq, V: Lattice> Lattice for ORMap<K, V>

Source§

fn merge(&self, other: &Self) -> Self

Compute the least upper bound of self and other.
Source§

impl<K: PartialEq + Ord, V: PartialEq + Lattice> PartialEq for ORMap<K, V>

Source§

fn eq(&self, other: &ORMap<K, V>) -> 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<K, V> Serialize for ORMap<K, V>
where K: Serialize + Ord, V: Serialize + Lattice,

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<K: Eq + Ord, V: Eq + Lattice> Eq for ORMap<K, V>

Source§

impl<K: Ord, V: Lattice> StructuralPartialEq for ORMap<K, V>

Auto Trait Implementations§

§

impl<K, V> Freeze for ORMap<K, V>

§

impl<K, V> RefUnwindSafe for ORMap<K, V>

§

impl<K, V> Send for ORMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for ORMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for ORMap<K, V>

§

impl<K, V> UnwindSafe for ORMap<K, V>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,