Struct garage_table::crdt::Map[][src]

pub struct Map<K, V> { /* fields omitted */ }
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

Create a new empty map CRDT

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.

Add a value to the map

Removes all values from the map

Get a reference to the value assigned to a key

Gets a reference to all of the items, as a slice. Usefull to iterate on all map values.

Returns the number of items in the map

Returns true if the map is empty

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Merge the two datastructures according to the CRDT rules. self is modified to contain the merged CRDT value. other is not modified. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more