Trait infinitree::fields::Collection
source · 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§
sourcetype Depth: Depth
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.
sourcetype Serialized: DeserializeOwned
type Serialized: DeserializeOwned
The serialized record format. This type will typically
implement serde::Serialize
Required Methods§
sourcefn key(from: &Self::Serialized) -> &Self::Key
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.
sourcefn load(from: Self::Serialized, object: &mut dyn Reader) -> Self::Item
fn load(from: Self::Serialized, object: &mut dyn Reader) -> Self::Item
Load the full record, and return it