pub trait PaginatedTableDataProvider<Row, Err: Debug = String> {
const PAGE_ROW_COUNT: usize;
// Required method
async fn get_page(&self, page_index: usize) -> Result<Vec<Row>, Err>;
// Provided methods
async fn row_count(&self) -> Option<usize> { ... }
async fn page_count(&self) -> Option<usize> { ... }
fn set_sorting(&mut self, sorting: &VecDeque<(usize, ColumnSort)>) { ... }
fn track(&self) { ... }
}
Expand description
A paginated data source. This is meant to provide a more convenient way
of connecting to a paginated data source instead of implementing TableDataProvider
directly.
If you implement this for your struct, TableDataProvider
is automatically implemented for you.
Please note that this is independent from using [
DisplayStrategy::Pagination
] with [TableContent
]. You do not have implement this trait if you’re using pagination and you vice versa if you’re not using pagination you can still implement this trait. And in case if you use this trait together with pagination the display row count can be different from thePAGE_ROW_COUNT
.
Required Associated Constants§
Sourceconst PAGE_ROW_COUNT: usize
const PAGE_ROW_COUNT: usize
How many rows per page
Required Methods§
Provided Methods§
Sourceasync fn row_count(&self) -> Option<usize>
async fn row_count(&self) -> Option<usize>
The total number of rows in the table. Returns None
if unknown (which is the default).
By default this is computed from the [page_count
] method. But if your data source
tells you the number of rows instead of the number of pages you should override this method.
Sourceasync fn page_count(&self) -> Option<usize>
async fn page_count(&self) -> Option<usize>
The total number of pages in the data source. Returns None
if unknown (which is the default).
If your data source gives you the number of rows instead of the number of pages
you should implement [row_count
] instead of this method.
Sourcefn set_sorting(&mut self, sorting: &VecDeque<(usize, ColumnSort)>)
fn set_sorting(&mut self, sorting: &VecDeque<(usize, ColumnSort)>)
Same as TableDataProvider::set_sorting
Sourcefn track(&self)
fn track(&self)
Same as TableDataProvider::track
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.