[−][src]Struct crdts::map::Map
Map CRDT - Supports Composition of CRDT's with reset-remove semantics.
Reset-remove means that if one replica removes an entry while another actor concurrently edits that entry, once we sync these two maps, we will see that the entry is still in the map but all edits seen by the removing actor will be gone.
See examples/reset_remove.rs for an example of reset-remove semantics in action.
Implementations
impl<K: Ord, V: Val<A> + Default, A: Actor> Map<K, V, A>
[src]
pub fn new() -> Self
[src]
Constructs an empty Map
pub fn is_empty(&self) -> ReadCtx<bool, A>
[src]
Returns true if the map has no entries, false otherwise
pub fn len(&self) -> ReadCtx<usize, A>
[src]
Returns the number of entries in the Map
pub fn get(&self, key: &K) -> ReadCtx<Option<V>, A>
[src]
Retrieve value stored under a key
pub fn update<F>(&self, key: impl Into<K>, ctx: AddCtx<A>, f: F) -> Op<K, V, A> where
F: FnOnce(&V, AddCtx<A>) -> V::Op,
[src]
F: FnOnce(&V, AddCtx<A>) -> V::Op,
Update a value under some key.
If the key is not present in the map, the updater will be given the
result of V::default()
. The default
value is used to ensure
eventual consistency since our Map
's values are CRDTs themselves.
The impl Into<K>
bound provides a nice way of providing an input key that
can easily convert to the Map
's key. For example, we can call this function
with "hello": &str
and it can be converted to String
.
pub fn rm(&self, key: impl Into<K>, ctx: RmCtx<A>) -> Op<K, V, A>
[src]
Remove an entry from the Map
The impl Into<K>
bound provides a nice way of providing an input key that
can easily convert to the Map
's key. For example, we can call this function
with "hello": &str
and it can be converted to String
.
pub fn read_ctx(&self) -> ReadCtx<(), A>
[src]
Retrieve the current read context
Trait Implementations
impl<K: Ord, V: Val<A> + Default, A: Actor> Causal<A> for Map<K, V, A>
[src]
impl<K: Clone + Ord, V: Clone + Val<A>, A: Clone + Actor> Clone for Map<K, V, A>
[src]
impl<K: Ord, V: Val<A> + Default, A: Actor> CmRDT for Map<K, V, A>
[src]
type Op = Op<K, V, A>
Op defines a mutation to the CRDT. As long as Op's from one actor are replayed in exactly the same order they were generated by that actor, the CRDT will converge. In other words, we must have a total ordering on each actors operations, while requiring only a partial order over all ops. E.g. Read more
fn apply(&mut self, op: Self::Op)
[src]
impl<K: Ord, V: Val<A> + Default, A: Actor> CvRDT for Map<K, V, A>
[src]
impl<K: Debug + Ord, V: Debug + Val<A>, A: Debug + Actor> Debug for Map<K, V, A>
[src]
impl<K: Ord, V: Val<A> + Default, A: Actor> Default for Map<K, V, A>
[src]
impl<'de, K: Ord, V: Val<A>, A: Actor> Deserialize<'de> for Map<K, V, A> where
K: Deserialize<'de>,
V: Deserialize<'de>,
A: Deserialize<'de>,
[src]
K: Deserialize<'de>,
V: Deserialize<'de>,
A: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<K: Eq + Ord, V: Eq + Val<A>, A: Eq + Actor> Eq for Map<K, V, A>
[src]
impl<K: PartialEq + Ord, V: PartialEq + Val<A>, A: PartialEq + Actor> PartialEq<Map<K, V, A>> for Map<K, V, A>
[src]
impl<K: Ord, V: Val<A>, A: Actor> Serialize for Map<K, V, A> where
K: Serialize,
V: Serialize,
A: Serialize,
[src]
K: Serialize,
V: Serialize,
A: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<K: Ord, V: Val<A>, A: Actor> StructuralEq for Map<K, V, A>
[src]
impl<K: Ord, V: Val<A>, A: Actor> StructuralPartialEq for Map<K, V, A>
[src]
Auto Trait Implementations
impl<K, V, A> RefUnwindSafe for Map<K, V, A> where
A: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
A: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, A> Send for Map<K, V, A> where
A: Send,
K: Send,
V: Send,
A: Send,
K: Send,
V: Send,
impl<K, V, A> Sync for Map<K, V, A> where
A: Sync,
K: Sync,
V: Sync,
A: Sync,
K: Sync,
V: Sync,
impl<K, V, A> Unpin for Map<K, V, A> where
A: Unpin,
K: Unpin,
V: Unpin,
A: Unpin,
K: Unpin,
V: Unpin,
impl<K, V, A> UnwindSafe for Map<K, V, A> where
A: RefUnwindSafe + UnwindSafe,
K: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe + UnwindSafe,
A: RefUnwindSafe + UnwindSafe,
K: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<A, T> Val<A> for T where
A: Actor,
T: Clone + Causal<A> + CmRDT + CvRDT,
[src]
A: Actor,
T: Clone + Causal<A> + CmRDT + CvRDT,