Skip to main content

build_offset_page

Function build_offset_page 

Source
pub fn build_offset_page(
    limit_in: u64,
    offset: u64,
    item_count: usize,
    total: u64,
    default_limit: u64,
    max_limit: u64,
) -> OffsetPage
Expand description

Normalize inputs and build an OffsetPage.

  • limit_in == 0default_limit
  • limit_in > max_limit → clamped to max_limit
  • has_more is derived from offset + item_count < total

§Example

use api_bones::connect::{build_offset_page, DEFAULT_LIMIT, MAX_LIMIT};

let page = build_offset_page(0, 0, 5, 100, DEFAULT_LIMIT, MAX_LIMIT);
assert_eq!(page.limit(), DEFAULT_LIMIT);
assert!(page.has_more());