[][src]Struct crdts::map::Map

pub struct Map<K: Ord, V: Val<A>, A: Actor> { /* fields omitted */ }

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]

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

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]

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]

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

impl<K, V, A> Send for Map<K, V, A> where
    A: Send,
    K: Send,
    V: Send

impl<K, V, A> Sync for Map<K, V, A> where
    A: Sync,
    K: Sync,
    V: Sync

impl<K, V, A> Unpin for Map<K, V, A> where
    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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<A, T> Val<A> for T where
    A: Actor,
    T: Clone + Causal<A> + CmRDT + CvRDT
[src]