pub struct Paginator {
pub display_type: Type,
pub active_dot: String,
pub inactive_dot: String,
pub arabic_format: String,
pub key_map: KeyMap,
/* private fields */
}Expand description
Pagination model.
Fields§
§display_type: TypeDisplay type (Arabic or Dots).
active_dot: StringCharacter for active page in Dots mode.
inactive_dot: StringCharacter for inactive pages in Dots mode.
arabic_format: StringFormat string for Arabic mode.
key_map: KeyMapKey bindings.
Implementations§
Source§impl Paginator
impl Paginator
Sourcepub fn display_type(self, t: Type) -> Self
pub fn display_type(self, t: Type) -> Self
Sets the display type.
Sourcepub fn total_pages(self, n: usize) -> Self
pub fn total_pages(self, n: usize) -> Self
Sets the total number of pages.
Sourcepub fn get_per_page(&self) -> usize
pub fn get_per_page(&self) -> usize
Returns the items per page.
Sourcepub fn get_total_pages(&self) -> usize
pub fn get_total_pages(&self) -> usize
Returns the total number of pages.
Sourcepub fn set_total_pages_from_items(&mut self, items: usize) -> usize
pub fn set_total_pages_from_items(&mut self, items: usize) -> usize
Calculates and sets the total pages from item count.
Returns the calculated total pages.
Sourcepub fn items_on_page(&self, total_items: usize) -> usize
pub fn items_on_page(&self, total_items: usize) -> usize
Returns the number of items on the current page.
Sourcepub fn get_slice_bounds(&self, length: usize) -> (usize, usize)
pub fn get_slice_bounds(&self, length: usize) -> (usize, usize)
Returns slice bounds for the current page.
Use this to get the start and end indices for slicing a collection.
§Example
use bubbles::paginator::Paginator;
let items = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let mut paginator = Paginator::new().per_page(3);
paginator.set_total_pages_from_items(items.len());
let (start, end) = paginator.get_slice_bounds(items.len());
assert_eq!(&items[start..end], &[1, 2, 3]);Sourcepub fn on_last_page(&self) -> bool
pub fn on_last_page(&self) -> bool
Returns whether we’re on the last page.
Sourcepub fn on_first_page(&self) -> bool
pub fn on_first_page(&self) -> bool
Returns whether we’re on the first page.
Sourcepub fn init(&self) -> Option<Cmd>
pub fn init(&self) -> Option<Cmd>
Initializes the paginator.
Paginators don’t require initialization commands.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Paginator
impl RefUnwindSafe for Paginator
impl Send for Paginator
impl Sync for Paginator
impl Unpin for Paginator
impl UnwindSafe for Paginator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more