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§
Sourcefn row_count(&mut self, query: &PageQuery) -> Result<u64, PageError>
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.
Sourcefn page(
&mut self,
query: &PageQuery,
offset: u64,
limit: usize,
) -> Result<Vec<RecordBatch>, PageError>
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§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".