leptos_windowing/loaders/
memory_loader.rs

1use std::ops::Range;
2
3/// Loader trait for loading items on-demand from an in-memory data source.
4///
5/// In this case we don't need async methods and everything is simple and synchronous.
6pub trait MemoryLoader {
7    /// The type of items that will be loaded.
8    type Item;
9
10    /// The type of the query data that will be used to load items.
11    ///
12    /// Can be used to filter or sort the items for example.
13    type Query;
14
15    /// Loads items from the given range, respecting the query.
16    fn load_items(&self, range: Range<usize>, query: &Self::Query) -> Vec<Self::Item>;
17
18    /// The total number of items of this data source with respect to the query.
19    fn item_count(&self, query: &Self::Query) -> usize;
20}