MemoryLoader

Trait MemoryLoader 

Source
pub trait MemoryLoader {
    type Item;
    type Query;

    // Required methods
    fn load_items(
        &self,
        range: Range<usize>,
        query: &Self::Query,
    ) -> Vec<Self::Item>;
    fn item_count(&self, query: &Self::Query) -> usize;
}
Expand description

Loader trait for loading items on-demand from an in-memory data source.

In this case we don’t need async methods and everything is simple and synchronous.

Required Associated Types§

Source

type Item

The type of items that will be loaded.

Source

type Query

The type of the query data that will be used to load items.

Can be used to filter or sort the items for example.

Required Methods§

Source

fn load_items( &self, range: Range<usize>, query: &Self::Query, ) -> Vec<Self::Item>

Loads items from the given range, respecting the query.

Source

fn item_count(&self, query: &Self::Query) -> usize

The total number of items of this data source with respect to the query.

Implementors§