pub struct Map<K, V> { /* private fields */ }Expand description
Simple CRDT Map
This types defines a CRDT for a map from keys to values. Values are CRDT types which can have their own updating logic.
Internally, the map is stored as a vector of keys and values, sorted by ascending key order.
This is why the key type K must implement Ord (and also to ensure a unique serialization,
such that two values can be compared for equality based on their hashes). As a consequence,
insertions take O(n) time. This means that Map should be used for reasonably small maps.
However, note that even if we were using a more efficient data structure such as a BTreeMap,
the serialization cost O(n) would still have to be paid at each modification, so we are
actually not losing anything here.
Implementations§
Source§impl<K, V> Map<K, V>
impl<K, V> Map<K, V>
Sourcepub fn put_mutator(k: K, v: V) -> Map<K, V>
pub fn put_mutator(k: K, v: V) -> Map<K, V>
Returns a map that contains a single mapping from the specified key to the specified value. This can be used to build a delta-mutator: when merged with another map, the value will be added or CRDT-merged if a previous value already exists.
Trait Implementations§
Source§impl<'de, K, V> Deserialize<'de> for Map<K, V>where
K: Deserialize<'de>,
V: Deserialize<'de>,
impl<'de, K, V> Deserialize<'de> for Map<K, V>where
K: Deserialize<'de>,
V: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Map<K, V>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Map<K, V>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<K, V> FromIterator<(K, V)> for Map<K, V>
A crdt map can be created from an iterator of key-value pairs.
Note that all keys in the iterator must be distinct:
this function will throw a panic if it is not the case.
impl<K, V> FromIterator<(K, V)> for Map<K, V>
A crdt map can be created from an iterator of key-value pairs. Note that all keys in the iterator must be distinct: this function will throw a panic if it is not the case.
Source§impl<K, V> Serialize for Map<K, V>
impl<K, V> Serialize for Map<K, V>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<K, V> Eq for Map<K, V>
impl<K, V> StructuralPartialEq for Map<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Map<K, V>
impl<K, V> RefUnwindSafe for Map<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Map<K, V>
impl<K, V> Sync for Map<K, V>
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnwindSafe for Map<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more