pub trait Collection {
    type Depth: Depth;
    type Key;
    type Serialized: DeserializeOwned;
    type Item;

    // Required methods
    fn key(from: &Self::Serialized) -> &Self::Key;
    fn load(from: Self::Serialized, object: &mut dyn Reader) -> Self::Item;
    fn insert(&mut self, record: Self::Item);
}
Expand description

Query an index field, but do not automatically load it into memory

To allow lazily loading data from e.g. a SparseField when relevant, a predicate is taken that controls the iterator.

This trait should be implemented on a type that also implements Strategy, and not on the field directly.

Required Associated Types§

source

type Depth: Depth

Use this strategy to load the collection.

Typically this will be one of two types:

  • Incremental if a collection requires crawling the full transaction history for an accurate representation after loading.
  • Snapshot if the collection is not versioned and therefore there’s no need to resolve the full the transaction list.
source

type Key

The key that the predicate will use to decide whether to pull more data into memory.

source

type Serialized: DeserializeOwned

The serialized record format. This type will typically implement serde::Serialize

source

type Item

This is equivalent to Iterator::Item, and should contain a full record that can be inserted into the in-memory store.

Required Methods§

source

fn key(from: &Self::Serialized) -> &Self::Key

Get the key based on the deserialized data. You want this to be a reference that’s easy to derive from the serialized data.

source

fn load(from: Self::Serialized, object: &mut dyn Reader) -> Self::Item

Load the full record, and return it

source

fn insert(&mut self, record: Self::Item)

Store the deserialized record in the collection

Implementors§

source§

impl<K, V> Collection for LocalField<Map<K, V>>where K: Key, V: Value,

source§

impl<K, V> Collection for SparseField<Map<K, V>>where K: Key, V: Value,

§

type Depth = Snapshot

§

type Key = K

§

type Serialized = (K, SizedPointer)

§

type Item = (K, V)

source§

impl<K, V> Collection for SparseField<VersionedMap<K, V>>where K: Key, V: Value,

§

type Depth = Incremental

§

type Key = K

§

type Serialized = (K, Option<SizedPointer>)

§

type Item = (K, Option<Arc<V>>)

source§

impl<K, V> Collection for VersionedMap<K, V>where K: Key, V: Value,

§

type Depth = Incremental

§

type Key = K

§

type Serialized = (K, Option<Arc<V>>)

§

type Item = (K, Option<Arc<V>>)

source§

impl<T> Collection for LocalField<LinkedList<T>>where T: Value + Clone,

§

type Depth = Incremental

§

type Key = T

§

type Serialized = T

§

type Item = T

source§

impl<T> Collection for LocalField<List<T>>where T: Value + Clone,

§

type Depth = Snapshot

§

type Key = T

§

type Serialized = T

§

type Item = T

source§

impl<T> Collection for SparseField<LinkedList<T>>where T: Value + Clone,

source§

impl<T> Collection for SparseField<List<T>>where T: Value + Clone,

source§

impl<T: Collection> Collection for LocalField<T>

§

type Depth = <T as Collection>::Depth

§

type Key = <T as Collection>::Key

§

type Serialized = <T as Collection>::Serialized

§

type Item = <T as Collection>::Item