Trait infinitree::fields::Collection[][src]

pub trait Collection {
    type Depth: Depth;
    type Key;
    type Serialized: DeserializeOwned;
    type Item;
    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); fn load_head(
        &mut self,
        _transaction: &mut Transaction,
        _object: &mut dyn Reader
    ) { ... } }
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.

Associated Types

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.

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

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

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

Required methods

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

Load the full record, and return it

Store the deserialized record in the collection

Provided methods

This function is called when initializing an iterator. It will typically read one-off book keeping information from the header of the field transaction.

Implementors