pub trait Paginator: Entity + Sized {
// Required method
fn paginate(pool: &PgPool) -> PaginatedQueryBuilder<'_, Self>;
// Provided methods
async fn fetch_paginated(
pool: &PgPool,
request: &PaginationRequest,
) -> Result<Paginated<Self>, PaginationError>
where Self: for<'r> FromRow<'r, PgRow> + Send + Unpin + Debug { ... }
async fn fetch_page(
pool: &PgPool,
page: u64,
per_page: u64,
) -> Result<Vec<Self>, PaginationError>
where Self: for<'r> FromRow<'r, PgRow> + Send + Unpin + Debug { ... }
async fn count(pool: &PgPool) -> Result<u64, PaginationError> { ... }
fn cursor_paginate(
pool: &PgPool,
cursor_column: impl Into<String>,
) -> CursorPaginator<'_, Self> { ... }
async fn fetch_cursor_paginated(
pool: &PgPool,
cursor_column: &str,
cursor: Option<Cursor>,
limit: u64,
_direction: CursorDirection,
) -> Result<CursorPaginated<Self>, PaginationError>
where Self: for<'r> FromRow<'r, PgRow> + Send + Unpin + Debug { ... }
}Expand description
Trait for paginating entities
This trait provides methods for paginating queries on entities
Required Methods§
Provided Methods§
Sourceasync fn fetch_paginated(
pool: &PgPool,
request: &PaginationRequest,
) -> Result<Paginated<Self>, PaginationError>
async fn fetch_paginated( pool: &PgPool, request: &PaginationRequest, ) -> Result<Paginated<Self>, PaginationError>
Sourceasync fn fetch_page(
pool: &PgPool,
page: u64,
per_page: u64,
) -> Result<Vec<Self>, PaginationError>
async fn fetch_page( pool: &PgPool, page: u64, per_page: u64, ) -> Result<Vec<Self>, PaginationError>
Sourcefn cursor_paginate(
pool: &PgPool,
cursor_column: impl Into<String>,
) -> CursorPaginator<'_, Self>
fn cursor_paginate( pool: &PgPool, cursor_column: impl Into<String>, ) -> CursorPaginator<'_, Self>
Sourceasync fn fetch_cursor_paginated(
pool: &PgPool,
cursor_column: &str,
cursor: Option<Cursor>,
limit: u64,
_direction: CursorDirection,
) -> Result<CursorPaginated<Self>, PaginationError>
async fn fetch_cursor_paginated( pool: &PgPool, cursor_column: &str, cursor: Option<Cursor>, limit: u64, _direction: CursorDirection, ) -> Result<CursorPaginated<Self>, PaginationError>
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.