pub trait PaginatorTrait<'db, C>where
C: ConnectionTrait,{
type Selector: SelectorTrait + Send + Sync + 'db;
// Required method
fn paginate(
self,
db: &'db C,
page_size: u64,
) -> Paginator<'db, C, Self::Selector>;
// Provided method
fn count<'async_trait>(
self,
db: &'db C,
) -> Pin<Box<dyn Future<Output = Result<u64, DbErr>> + Send + 'async_trait>>
where 'db: 'async_trait,
Self: Sized + Send + 'async_trait { ... }
}Expand description
Extension trait that adds .paginate(db, page_size) to anything
page-able — Select, SelectTwo,
Selector, SelectorRaw.
Required Associated Types§
Sourcetype Selector: SelectorTrait + Send + Sync + 'db
type Selector: SelectorTrait + Send + Sync + 'db
The SelectorTrait that materialises each row of the page.
Required Methods§
Provided Methods§
Sourcefn count<'async_trait>(
self,
db: &'db C,
) -> Pin<Box<dyn Future<Output = Result<u64, DbErr>> + Send + 'async_trait>>
fn count<'async_trait>( self, db: &'db C, ) -> Pin<Box<dyn Future<Output = Result<u64, DbErr>> + Send + 'async_trait>>
Count the number of rows this query selects, honoring any limit and
offset set on it.
This differs from Paginator::num_items, which resets limit/offset
to report the grand total for pagination. count wraps the query as-is in
a SELECT COUNT(*) FROM (..) subquery, so a query with a limit counts at
most that many rows.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".