pub trait PaginatedLoader {
type Item;
type Query;
type Error: Debug + 'static;
const PAGE_ITEM_COUNT: usize;
// Required method
fn load_page(
&self,
page_index: usize,
query: &Self::Query,
) -> impl Future<Output = Result<Vec<Self::Item>, Self::Error>>;
// Provided method
fn count(
&self,
_query: &Self::Query,
) -> impl Future<Output = Result<Option<PaginatedCount>, Self::Error>> { ... }
}Expand description
Loader trait for loading items on-demand from a paginated data source.
Please note that this is independent of if you use pagination or virtualization in your UI. This just referrs to the data source. So if you have an API for example, that returns the data paginated, then this is for you.
Required Associated Constants§
Sourceconst PAGE_ITEM_COUNT: usize
const PAGE_ITEM_COUNT: usize
How many rows per page
Required Associated Types§
Required Methods§
Sourcefn load_page(
&self,
page_index: usize,
query: &Self::Query,
) -> impl Future<Output = Result<Vec<Self::Item>, Self::Error>>
fn load_page( &self, page_index: usize, query: &Self::Query, ) -> impl Future<Output = Result<Vec<Self::Item>, Self::Error>>
Get all data items specified by the page index (starts a 0) and the query.
If you return less than PAGE_ITEM_COUNT rows, it is assumed that the end of the
data has been reached.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.