pub struct Paginator<T, C, R, Fetch, Fut, Extract>where
C: Clone,
Fetch: FnMut(Option<C>) -> Fut,
Fut: Future<Output = Result<R>>,
Extract: FnMut(R) -> Result<EdgePage<T, C>>,{ /* private fields */ }Expand description
generic paginator for connection-style data
Implementations§
Source§impl<T, C, R, Fetch, Fut, Extract> Paginator<T, C, R, Fetch, Fut, Extract>
impl<T, C, R, Fetch, Fut, Extract> Paginator<T, C, R, Fetch, Fut, Extract>
Sourcepub fn with_max_pages(self, max_pages: usize) -> Self
pub fn with_max_pages(self, max_pages: usize) -> Self
cap how many pages the walk may fetch
unset by default. asking for a page beyond the cap yields
Error::PaginationLimit instead of the page.
Source§impl<T, C, R, Fetch, Fut, Extract> Paginator<T, C, R, Fetch, Fut, Extract>
impl<T, C, R, Fetch, Fut, Extract> Paginator<T, C, R, Fetch, Fut, Extract>
Sourcepub async fn next_page(&mut self) -> Result<Option<Vec<T>>>
pub async fn next_page(&mut self) -> Result<Option<Vec<T>>>
fetch the next page of results
fails with Error::PaginationStalled if the page carries a cursor the
walk already used within the last 16 fetches. that catches a server
repeating one cursor and a server cycling through up to 16 of them; a
cycle longer than the window is not detected and is bounded only by
Paginator::with_max_pages, which fails with
Error::PaginationLimit once exceeded. both errors end the walk:
later calls return Ok(None) without another fetch.
Sourcepub async fn collect_all(self) -> Result<Vec<T>>
pub async fn collect_all(self) -> Result<Vec<T>>
fetch all pages and return a single collection
unbounded unless Paginator::with_max_pages is set: the stall guard
on Paginator::next_page ends a short cursor cycle, not a long one.