Struct paginator::PaginatorBuilder
source · 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: usize
The number of pages.
current_page: usize
The number of the current page.
max_item_count: usize
The max number of PageItem
s after generated.
start_size: usize
The number of PageItem
s (the PageItem::Prev
item is excluded) on the start edge (before the first PageItem::Ignore
item).
end_size: usize
The number of PageItem
s (the PageItem::Next
item is excluded) on the end edge (after the last PageItem::Ignore
item).
has_prev: YesNoDepends
Whether to add the PageItem::Prev
item.
has_next: YesNoDepends
Whether 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 PageItem
s 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 PageItem
s (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 PageItem
s (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 moresource§impl Debug for PaginatorBuilder
impl Debug for PaginatorBuilder
source§impl PartialEq<PaginatorBuilder> for PaginatorBuilder
impl PartialEq<PaginatorBuilder> for PaginatorBuilder
source§fn eq(&self, other: &PaginatorBuilder) -> bool
fn eq(&self, other: &PaginatorBuilder) -> bool
self
and other
values to be equal, and is used
by ==
.