pub enum PaginationStyle {
None,
Cursor {
next_token_path: String,
param_name: String,
},
CursorInBody {
next_token_path: String,
body_cursor_field: String,
},
LinkHeader,
NextLinkInBody {
next_link_path: String,
},
PageNumber {
param_name: String,
start_page: usize,
page_size: Option<usize>,
page_size_param: Option<String>,
},
Offset {
offset_param: String,
limit_param: String,
limit: usize,
total_path: Option<String>,
},
OffsetInBody {
offset_field: String,
limit_field: String,
limit: usize,
stop_when_short: bool,
},
RecordFieldCursor {
field: String,
into: RecordCursorTarget,
param: String,
agg: RecordCursorAgg,
stop_when_short: bool,
page_size: usize,
},
}Expand description
Supported pagination strategies.
Variants§
None
Cursor
CursorInBody
POST-search pagination: the next-page cursor is read from the response
body via next_token_path and written into the request JSON body at
body_cursor_field for the next request (rather than a query param).
The first request uses config.body unchanged; each subsequent request
sets body[body_cursor_field] = <extracted cursor>. Pagination stops when
next_token_path is null/absent, and a repeated cursor trips the same
loop guard as PaginationStyle::Cursor. Used by e.g. HubSpot CRM
POST /crm/v3/objects/{obj}/search ($.paging.next.after → after).
LinkHeader
NextLinkInBody
The full URL of the next page is embedded in the response body.
next_link_path is a JSONPath expression pointing to that URL field
(e.g. "$.next_link"). Pagination stops when the field is absent,
null, or an empty string.
PageNumber
Fields
Offset
OffsetInBody
Offset/limit pagination that writes the offset and limit into the JSON
request body (POST-query APIs), rather than the query string
(Offset) or a cursor token
(CursorInBody). Each request sends
body[offset_field] = <offset> and body[limit_field] = <limit>; the
offset advances by the page’s record count. With stop_when_short
(default true) a page shorter than limit ends pagination; a zero-record
page always ends it, and a repeated identical page trips a loop guard.
RecordFieldCursor
Keyset pagination by the running max/min of a record field (#554). After
each page the aggregate of field over its records is injected into the
next request (as a query param or body field per into) at param. With
stop_when_short (default true) a page shorter than page_size ends
pagination; a zero-record page always ends it, and a non-advancing cursor
trips a loop guard.
Fields
into: RecordCursorTargetWhere the cursor is injected on the next request (default query).
agg: RecordCursorAggAggregation over the page (default max).
Implementations§
Source§impl PaginationStyle
impl PaginationStyle
pub fn apply_params( &self, params: &mut HashMap<String, String>, state: &PaginationState, )
Sourcepub fn advance(
&self,
body: &Value,
headers: &HeaderMap,
state: &mut PaginationState,
record_count: usize,
) -> Result<bool, FaucetError>
pub fn advance( &self, body: &Value, headers: &HeaderMap, state: &mut PaginationState, record_count: usize, ) -> Result<bool, FaucetError>
Advance pagination state based on the response body and headers.
Returns true if there is a next page to fetch.
Includes loop detection: if a cursor or next-link value is identical to the previous page’s value, pagination stops with a warning instead of looping forever.
Sourcepub fn update_record_cursor(
&self,
records: &[Value],
state: &mut PaginationState,
)
pub fn update_record_cursor( &self, records: &[Value], state: &mut PaginationState, )
Compute this page’s keyset cursor for PaginationStyle::RecordFieldCursor
(#554), merging the page aggregate of field into state.record_field_cursor.
A no-op for every other style. Call this with the page’s records before
advance.
Sourcepub fn cursor_path(&self) -> Option<&str>
pub fn cursor_path(&self) -> Option<&str>
The JSONPath a cursor style reads its next-page token from
(Cursor / CursorInBody); used by
the resumable-cursor bookmark (#547). None for every other style.
Sourcepub fn body_params(&self, state: &PaginationState) -> Vec<(String, Value)>
pub fn body_params(&self, state: &PaginationState) -> Vec<(String, Value)>
Request-body fields to inject for body-carrying pagination styles
(CursorInBody, OffsetInBody, and RecordFieldCursor with into: body).
Empty for every other style, and for the first page of a cursor style
(nothing extracted yet). Supersedes body_cursor,
which is retained for API compatibility.
Sourcepub fn body_cursor<'a>(
&'a self,
state: &'a PaginationState,
) -> Option<(&'a str, &'a str)>
pub fn body_cursor<'a>( &'a self, state: &'a PaginationState, ) -> Option<(&'a str, &'a str)>
For PaginationStyle::CursorInBody, the (body_cursor_field, cursor)
to inject into the next request’s JSON body — Some only once a cursor
has been extracted (i.e. from the second page on). Every other style, and
the first page of CursorInBody, returns None (the request body is
used unchanged).
Trait Implementations§
Source§impl Clone for PaginationStyle
impl Clone for PaginationStyle
Source§fn clone(&self) -> PaginationStyle
fn clone(&self) -> PaginationStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PaginationStyle
impl Debug for PaginationStyle
Source§impl<'de> Deserialize<'de> for PaginationStyle
impl<'de> Deserialize<'de> for PaginationStyle
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for PaginationStyle
impl JsonSchema for PaginationStyle
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more