pub struct PaginatorBuilder {
pub total_pages: usize,
pub current_page: usize,
pub max_item_count: usize,
pub start_size: usize,
pub end_size: usize,
pub has_prev: YesNoDepends,
pub has_next: YesNoDepends,
}Expand description
A struct to create Paginator or PaginatorIter.
Fields§
§total_pages: usizeThe number of pages.
current_page: usizeThe number of the current page.
max_item_count: usizeThe max number of PageItems after generated.
start_size: usizeThe number of PageItems (the PageItem::Prev item is excluded) on the start edge (before the first PageItem::Ignore item).
end_size: usizeThe number of PageItems (the PageItem::Next item is excluded) on the end edge (after the last PageItem::Ignore item).
has_prev: YesNoDependsWhether to add the PageItem::Prev item.
has_next: YesNoDependsWhether to add the PageItem::Next item.
Implementations§
Source§impl PaginatorBuilder
impl PaginatorBuilder
Sourcepub const fn new(total_pages: usize) -> PaginatorBuilder
pub const fn new(total_pages: usize) -> PaginatorBuilder
Create a new PaginatorBuilder with some default options.
PaginatorBuilder {
total_pages, // this is input by the caller.
current_page: 1,
max_item_count: 9,
start_size: 1,
end_size: 1,
has_prev: YesNoDepends::Depends,
has_next: YesNoDepends::Depends,
}Sourcepub const fn total_pages(self, total_pages: usize) -> PaginatorBuilder
pub const fn total_pages(self, total_pages: usize) -> PaginatorBuilder
Set the number of pages.
Sourcepub const fn current_page(self, current_page: usize) -> PaginatorBuilder
pub const fn current_page(self, current_page: usize) -> PaginatorBuilder
Set the number of the current page.
Sourcepub const fn max_item_count(self, max_item_count: usize) -> PaginatorBuilder
pub const fn max_item_count(self, max_item_count: usize) -> PaginatorBuilder
Set the max number of PageItems after generated.
Sourcepub const fn start_size(self, start_size: usize) -> PaginatorBuilder
pub const fn start_size(self, start_size: usize) -> PaginatorBuilder
Set the number of PageItems (the PageItem::Prev item is excluded) on the start edge (before the first PageItem::Ignore item).
Sourcepub const fn end_size(self, end_size: usize) -> PaginatorBuilder
pub const fn end_size(self, end_size: usize) -> PaginatorBuilder
Set the number of PageItems (the PageItem::Next item is excluded) on the end edge (after the last PageItem::Ignore item).
Sourcepub const fn has_prev(self, has_prev: YesNoDepends) -> PaginatorBuilder
pub const fn has_prev(self, has_prev: YesNoDepends) -> PaginatorBuilder
Set whether to add the PageItem::Prev item.
Sourcepub const fn has_next(self, has_next: YesNoDepends) -> PaginatorBuilder
pub const fn has_next(self, has_next: YesNoDepends) -> PaginatorBuilder
Set whether to add the PageItem::Next item.
Source§impl PaginatorBuilder
impl PaginatorBuilder
pub fn build_paginator(self) -> Result<Paginator, PaginatorBuildError>
pub fn build_paginator_iter(self) -> Result<PaginatorIter, PaginatorBuildError>
Trait Implementations§
Source§impl Clone for PaginatorBuilder
impl Clone for PaginatorBuilder
Source§fn clone(&self) -> PaginatorBuilder
fn clone(&self) -> PaginatorBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more