aboutsummaryrefslogtreecommitdiff
path: root/src/util/crdt/lww_map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crdt/lww_map.rs')
-rw-r--r--src/util/crdt/lww_map.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/crdt/lww_map.rs b/src/util/crdt/lww_map.rs
index 3e9aba79..21cb6e12 100644
--- a/src/util/crdt/lww_map.rs
+++ b/src/util/crdt/lww_map.rs
@@ -30,8 +30,8 @@ pub struct LwwMap<K, V> {
impl<K, V> LwwMap<K, V>
where
- K: Ord,
- V: Crdt,
+ K: Clone + Ord,
+ V: Clone + Crdt,
{
/// Create a new empty map CRDT
pub fn new() -> Self {
@@ -73,6 +73,10 @@ where
};
Self { vals: new_vals }
}
+
+ pub fn update_in_place(&mut self, k: K, new_v: V) {
+ self.merge(&self.update_mutator(k, new_v));
+ }
/// Takes all of the values of the map and returns them. The current map is reset to the
/// empty map. This is very usefull to produce in-place a new map that contains only a delta
/// that modifies a certain value:
@@ -158,8 +162,8 @@ where
impl<K, V> Default for LwwMap<K, V>
where
- K: Ord,
- V: Crdt,
+ K: Clone + Ord,
+ V: Clone + Crdt,
{
fn default() -> Self {
Self::new()