pagino

Crates.iopagino
lib.rspagino
version1.0.5
sourcesrc
created_at2021-02-24 17:56:03.681552
updated_at2021-03-06 13:28:48.062326
descriptionHandle pagination's logic
homepagehttps://github.com/pagino/pagino-rust
repositoryhttps://github.com/pagino/pagino-rust
max_upload_size
id360066
size8,643
Behnam Mohammadi (behnammodi)

documentation

https://github.com/pagino/pagino-rust

README

Pagino

Handle pagination's logic

Usage

Add this to your Cargo.toml:

[dependencies]
pagino = "1.0.5"

Example

use pagino::Pagino;

fn main(){
  let mut pagino = Pagino::new(true, true, true, true, 1, 10, 1, 1);

  let pages: Vec<i32> = pagino.get_pages();
  /*
    pages: [-1, -2, 1, 2, 3, 4, 5, -4, 10, -5, -6];
  */

  pagino.set_page(10);
  let pages: Vec<i32> = pagino.get_pages();
  /*
    pages: [-1, -2, 1, -3, 6, 7, 8, 9, 10, -5, -6];
  */

  pagino.set_page(5);
  let pages: Vec<i32> = pagino.get_pages();
  /*
    pages: [-1, -2, 1, -3, 4, 5, 6, -4, 10, -5, -6];
  */
}

Methods:

pagino.get_pages() -> Vec<i32>;
pagino.set_page(i32) -> ();
pagino.set_count(i32) -> ();

pagino.first() -> ();
pagino.previous() -> ();
pagino.next() -> ();
pagino.last() -> ();

What are negative numbers?

All negative numbers are navigate element

-1  First
-2  Previous
-3  Start ellipsis
-4  End ellipsis
-5  Next
-6  Last

Pagino config

show_first: bool
show_previous: bool
show_next: bool
show_last: bool
page: i32
count: i32
sibling_count: i32
boundary_count: i32

Links:

https://github.com/pagino/pagino-rust

https://crates.io/crates/pagino

Commit count: 11

cargo fmt