pub struct CRDTMap<K: Ord + Clone> {
entries: BTreeMap<K, BTreeMap<Dot, MapValue>>,
context: CausalContext,
local_seq: u64,
}Expand description
Map CRDT - composable container for nested CRDTs
Maps keys to values, each value is tagged with a dot. A value is “live” if its dot is in the context. A value is “removed” if its dot is in the context but not in the store.
Fields§
§entries: BTreeMap<K, BTreeMap<Dot, MapValue>>Maps keys to dots that have been written to this key
context: CausalContextShared causal context: all dots that have been created or seen
local_seq: u64Sequence number for generating dots on this replica
Implementations§
Source§impl<K: Ord + Clone> CRDTMap<K>
impl<K: Ord + Clone> CRDTMap<K>
Sourcepub fn put(&mut self, replica_id: &str, key: K, value: MapValue) -> Dot
pub fn put(&mut self, replica_id: &str, key: K, value: MapValue) -> Dot
Put a value at a key (from this replica)
Sourcepub fn get(&self, key: &K) -> Option<&MapValue>
pub fn get(&self, key: &K) -> Option<&MapValue>
Get the current value at a key Returns the value if the key exists and has live entries
Sourcepub fn get_all(&self, key: &K) -> Vec<&MapValue>
pub fn get_all(&self, key: &K) -> Vec<&MapValue>
Get all values at a key (for concurrent writes)
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Check if a key exists with live values
Sourcepub fn context(&self) -> &CausalContext
pub fn context(&self) -> &CausalContext
Get the causal context
Sourcepub fn put_with_dot(&mut self, key: K, dot: Dot, value: MapValue)
pub fn put_with_dot(&mut self, key: K, dot: Dot, value: MapValue)
Add a value with a specific dot (for merging)
Trait Implementations§
Source§impl<'de, K: Ord + Clone + Deserialize<'de>> Deserialize<'de> for CRDTMap<K>
impl<'de, K: Ord + Clone + Deserialize<'de>> Deserialize<'de> for CRDTMap<K>
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: Ord + Clone> Lattice for CRDTMap<K>
impl<K: Ord + Clone> Lattice for CRDTMap<K>
Source§fn join(&self, other: &Self) -> Self
fn join(&self, other: &Self) -> Self
Join operation: merge all entries and contexts For each key, union all the dots and their values