pub struct ORMap<K, V: Merge + Default + Clone> { /* private fields */ }Expand description
An observed-remove map with nested CRDT values.
Keys are managed with OR-Set add-wins semantics. Values are merged using their CRDT merge function.
Implementations§
Source§impl<K: Hash + Eq + Clone, V: Merge + Default + Clone> ORMap<K, V>
impl<K: Hash + Eq + Clone, V: Merge + Default + Clone> ORMap<K, V>
Sourcepub fn new_random() -> Self
pub fn new_random() -> Self
Create a new map with a random replica ID.
Sourcepub fn get_or_insert(&mut self, key: K) -> &mut V
pub fn get_or_insert(&mut self, key: K) -> &mut V
Get a mutable reference to a value, creating the key if necessary. Always creates a new dot to ensure add-wins semantics.
Sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut V>
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
Get a mutable reference to a value without creating a new dot. Use this for read-heavy access patterns where add-wins isn’t needed.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Check if a key exists in the map.
Source§impl<K: Hash + Eq + Clone + Ord, V: Merge + Default + Clone> ORMap<K, V>
impl<K: Hash + Eq + Clone + Ord, V: Merge + Default + Clone> ORMap<K, V>
Sourcepub fn sorted_entries(&self) -> Vec<(&K, &V)>
pub fn sorted_entries(&self) -> Vec<(&K, &V)>
The present entries sorted by key. A merged map has no global insertion order, so this is the order every replica holding the same state renders and iterates in.
Trait Implementations§
Source§impl<K: Hash + Eq + Clone + Serialize + DeserializeOwned + Send + 'static, V: Merge + Default + Clone + Serialize + DeserializeOwned + Send + 'static> DeltaCrdt for ORMap<K, V>
impl<K: Hash + Eq + Clone + Serialize + DeserializeOwned + Send + 'static, V: Merge + Default + Clone + Serialize + DeserializeOwned + Send + 'static> DeltaCrdt for ORMap<K, V>
Source§impl<'de, K, V> Deserialize<'de> for ORMap<K, V>where
K: Serialize + DeserializeOwned + Hash + Eq,
V: Serialize + DeserializeOwned + Merge + Default + Clone,
impl<'de, K, V> Deserialize<'de> for ORMap<K, V>where
K: Serialize + DeserializeOwned + Hash + Eq,
V: Serialize + DeserializeOwned + Merge + Default + Clone,
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>,
Source§impl<K: Hash + Eq + Clone + Ord, T: Ord + Clone + Default> IntoIterator for ORMap<K, LatestWrite<T>>
Owned iteration over a map to plain values visits (key, value) pairs by key.
impl<K: Hash + Eq + Clone + Ord, T: Ord + Clone + Default> IntoIterator for ORMap<K, LatestWrite<T>>
Owned iteration over a map to plain values visits (key, value) pairs by key.
Source§impl<K: Hash + Eq + Clone, V: Merge + Default + Clone> LogosContains<K> for ORMap<K, V>
m contains key — observed-remove key membership.
impl<K: Hash + Eq + Clone, V: Merge + Default + Clone> LogosContains<K> for ORMap<K, V>
m contains key — observed-remove key membership.
Source§fn logos_contains(&self, key: &K) -> bool
fn logos_contains(&self, key: &K) -> bool
Source§impl<K: Hash + Eq + Clone + Display, T: Ord + Clone + Default> LogosIndex<K> for ORMap<K, LatestWrite<T>>
m[key] on a map to plain values: the value under a PRESENT key; a missing key traps with the
same message the interpreter raises.
impl<K: Hash + Eq + Clone + Display, T: Ord + Clone + Default> LogosIndex<K> for ORMap<K, LatestWrite<T>>
m[key] on a map to plain values: the value under a PRESENT key; a missing key traps with the
same message the interpreter raises.
Source§impl<K: Hash + Eq + Clone + Display, T: Ord + Clone + Default> LogosIndexMut<K> for ORMap<K, LatestWrite<T>>
Set m[key] to value on a map to plain values.
impl<K: Hash + Eq + Clone + Display, T: Ord + Clone + Default> LogosIndexMut<K> for ORMap<K, LatestWrite<T>>
Set m[key] to value on a map to plain values.
Source§impl<K: Hash + Eq, V: Merge + Default + Clone + PartialEq> PartialEq for ORMap<K, V>
Two maps are equal when they hold the same convergent state (keys with their dots, values, and
causal context) — the same rule as ORSet; the replica id is identity, not state.
impl<K: Hash + Eq, V: Merge + Default + Clone + PartialEq> PartialEq for ORMap<K, V>
Two maps are equal when they hold the same convergent state (keys with their dots, values, and
causal context) — the same rule as ORSet; the replica id is identity, not state.