leptos_struct_table

Trait PaginatedTableDataProvider

Source
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 the PAGE_ROW_COUNT.

Required Associated Constants§

Source

const PAGE_ROW_COUNT: usize

How many rows per page

Required Methods§

Source

async fn get_page(&self, page_index: usize) -> Result<Vec<Row>, Err>

Get all data rows for the table specified by the page index (starts a 0).

If you return less than PAGE_ROW_COUNT rows, it is assumed that the end of the data has been reached.

Provided Methods§

Source

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.

Source

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.

Source

fn set_sorting(&mut self, sorting: &VecDeque<(usize, ColumnSort)>)

Source

fn track(&self)

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.

Implementors§