Skip to main content

PageSource

Trait PageSource 

Source
pub trait PageSource: Send + 'static {
    // Required methods
    fn row_count(&mut self, query: &PageQuery) -> Result<u64, PageError>;
    fn page(
        &mut self,
        query: &PageQuery,
        offset: u64,
        limit: usize,
    ) -> Result<Vec<RecordBatch>, PageError>;

    // Provided method
    fn can_sort(&self, column: &str) -> bool { ... }
}
Expand description

The rows of a table too large to hold, a page at a time: what a PagedModel reads. Its calls (but can_sort) run on a thread of the model’s own, so a call may take as long as it needs: a query to a database or a query engine. A call is not interrupted; the next waits for it. Rows are numbered from 0 in the order the query gives them.

A call that fails, or panics (with panics unwinding, the default), is reported by the model (PagedModel::error), and the next calls go on.

Required Methods§

Source

fn row_count(&mut self, query: &PageQuery) -> Result<u64, PageError>

How many rows query gives.

§Errors

Any the source meets: the model shows no rows (FetchError::Count) until retry or refresh counts them again.

Source

fn page( &mut self, query: &PageQuery, offset: u64, limit: usize, ) -> Result<Vec<RecordBatch>, PageError>

limit rows from row offset of what query gives (fewer only at the end), in as many batches as they come in, each with the model’s columns: their data types, in order (names are not compared). The model asks for pages side by side in one call; when such a call fails, it asks for each of its pages alone.

§Errors

Any the source meets: those rows stay empty (FetchError::Rows) until retry or refresh. Fewer rows than asked for before the end say the data changed since it was counted (FetchError::Short).

Provided Methods§

Source

fn can_sort(&self, column: &str) -> bool

Whether the source can give its rows sorted by column: a click on its title sorts only then. Asked once for each column when the model is made, on the thread making it; every column can by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§