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 serialized record format. This type will typically
implement serde::Serialize
Required methods
fn 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.
fn 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
Provided methods
fn load_head(
&mut self,
_transaction: &mut Transaction,
_object: &mut dyn Reader
)
fn load_head(
&mut self,
_transaction: &mut Transaction,
_object: &mut dyn Reader
)
This function is called when initializing an iterator. It will typically read one-off book keeping information from the header of the field transaction.