Skip to main content

Module pagination

Module pagination 

Source
Expand description

Pagination types for list endpoints.

Supports both offset-based and cursor-based pagination patterns. All types are framework-agnostic — consumers add their own framework derives (e.g. utoipa::ToSchema, utoipa::IntoParams).

§Choosing a pagination strategy

§Offset-based (PaginatedResponse + PaginationParams)

  • Best for: admin dashboards, internal tools, small bounded datasets
  • Supports: random page access (jump to page N), total count
  • Trade-off: pages can shift when rows are inserted/deleted between requests
  • Use when: dataset is small (<10k rows), real-time consistency is not critical

§Cursor-based (CursorPaginatedResponse + CursorPaginationParams)

  • Best for: public APIs, feeds, large or live datasets
  • Supports: stable iteration (no skipped/duplicate items on insert)
  • Trade-off: no random page access, no total count
  • Use when: dataset is large or frequently mutated, API is public-facing
  • Industry standard: Stripe, GitHub, Slack all use cursor-based for list endpoints

Structs§

CursorPaginatedResponse
Cursor-based paginated response envelope (PLATFORM-003).
CursorPagination
Cursor-based pagination metadata (PLATFORM-003).
CursorPaginationParams
Query parameters for cursor-based list endpoints.
KeysetPaginatedResponse
A page of results from a keyset-paginated endpoint.
KeysetPaginationParams
Query parameters for keyset (seek-based) pagination.
PaginatedResponse
Offset-based paginated response envelope with a flat shape.
PaginationParams
Query parameters for offset-based list endpoints.