DotFunMap

Struct DotFunMap 

Source
pub struct DotFunMap<V> { /* private fields */ }
Expand description

A map from Dot to V: DotStore, whose computed dots is the union of the dots of its values.

Quoth the DSON paper:

We combine the DotMap and DotFun to get a dot store which maps dots to dot stores. The join operation keeps keys that have not been deleted (as in the DotFun), or the values themselves haven’t been deleted (as in the DotMap).

Note that this is called CompDotFun in the DSON paper (section 5.1), but DotFunMap in their prototype implementation.

Implementations§

Source§

impl<V> DotFunMap<V>

Source

pub fn with_capacity(capacity: usize) -> Self

Constructs a DotFunMap with the given initial capacity.

Source

pub fn iter(&self) -> impl ExactSizeIterator<Item = (Dot, &V)>

Produces an iterator over the map’s keys and values.

Source

pub fn keys(&self) -> impl ExactSizeIterator<Item = Dot> + '_

Produces an iterator over the map’s keys.

Source

pub fn values(&self) -> impl ExactSizeIterator<Item = &V>

Produces an iterator over the map’s values.

Source

pub fn len(&self) -> usize

Returns the number of keys in the map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map is empty.

Source§

impl<V> DotFunMap<V>

Source

pub fn get(&self, dot: &Dot) -> Option<&V>

Retrieves the associated value, if any, for the given Dot.

Source

pub fn get_mut(&mut self, dot: &Dot) -> Option<&mut V>

Retrieves a mutable reference to the associated value, if any, for the given Dot.

Source

pub fn has(&self, dot: &Dot) -> bool

Returns true if the given Dot has a value in this map.

Source

pub fn set(&mut self, dot: Dot, value: V) -> Option<V>

Associates the value with the given Dot.

Returns the previous value if any.

Trait Implementations§

Source§

impl<V: Clone> Clone for DotFunMap<V>

Source§

fn clone(&self) -> DotFunMap<V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug> Debug for DotFunMap<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V> Default for DotFunMap<V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, V> Deserialize<'de> for DotFunMap<V>
where V: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<V> DotStore for DotFunMap<V>
where V: DotStore + Debug,

Source§

fn add_dots_to(&self, other: &mut CausalContext)

Add the set of event identifiers (ie, dots) currently stored in the dot store to other. Read more
Source§

fn is_bottom(&self) -> bool

Returns true if this dot store is ⊥ (ie, empty).
Source§

fn subset_for_inflation_from(&self, frontier: &CausalContext) -> Self

Returns a subset-CRDT derived from self that allows inflating state at the vector time frontier to what’s in self.
Source§

fn dots(&self) -> CausalContext

Queries the set of event identifiers (ie, dots) currently stored in the dot store. Read more
Source§

impl<V, S> DotStoreJoin<S> for DotFunMap<V>
where V: DotStoreJoin<S> + Debug + Default, S: Visit<Dot> + KeySentinel,

Source§

fn join( (m1, cc1): (Self, &CausalContext), (m2, cc2): (Self, &CausalContext), on_dot_change: &mut dyn FnMut(DotChange), sentinel: &mut S, ) -> Result<Self, S::Error>
where S: Sentinel,

Formally (Equation 7):

(𝑚, 𝑐) ⊔ (𝑚′, 𝑐′) = ( {𝑑 ↦ 𝑣(𝑑) | 𝑑 ∈ dom 𝑚 ∩ dom 𝑚′ ∧ 𝑣(𝑑) ≠ ⊥} ∪ {(𝑑, 𝑣) ∈ 𝑚 | 𝑑 ∉ 𝑐′} ∪ {(𝑑, 𝑣) ∈ 𝑚′ | 𝑑 ∉ 𝑐} , 𝑐 ∪ 𝑐′ ) where 𝑣(𝑑) = fst((𝑚(𝑑), 𝑐) ⊔ (𝑚′(𝑑), 𝑐′))

Informally:

  • for dots in both stores, join the values and keep non-bottoms
  • for dots in store 1 that haven’t beeen observed by store 2, keep the value
  • for dots in store 2 that haven’t beeen observed by store 1, keep the value
  • don’t keep other dots
  • the resulting causal context is the union of the provided causal contexts
Source§

fn dry_join( (m1, cc1): (&Self, &CausalContext), (m2, cc2): (&Self, &CausalContext), sentinel: &mut S, ) -> Result<DryJoinOutput, S::Error>
where S: Sentinel,

Simulates a DotStoreJoin::join without constructing the output of the join. Read more
Source§

impl<V> FromIterator<(Dot, V)> for DotFunMap<V>

Source§

fn from_iter<T: IntoIterator<Item = (Dot, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<V: PartialEq> PartialEq for DotFunMap<V>

Source§

fn eq(&self, other: &DotFunMap<V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V> Serialize for DotFunMap<V>
where V: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<V: Eq> Eq for DotFunMap<V>

Source§

impl<V> StructuralPartialEq for DotFunMap<V>

Auto Trait Implementations§

§

impl<V> Freeze for DotFunMap<V>

§

impl<V> RefUnwindSafe for DotFunMap<V>
where V: RefUnwindSafe,

§

impl<V> Send for DotFunMap<V>
where V: Send,

§

impl<V> Sync for DotFunMap<V>
where V: Sync,

§

impl<V> Unpin for DotFunMap<V>
where V: Unpin,

§

impl<V> UnwindSafe for DotFunMap<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

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