paginate

Function paginate 

Source
pub fn paginate<T, F, Fut>(
    fetch_page: F,
) -> impl Stream<Item = Result<T, Error>>
where T: 'static, F: Fn(Option<String>) -> Fut + Clone + 'static, Fut: Future<Output = Result<Page<T>, Error>>,
Expand description

Creates a paginated stream from a fetch function.

This helper handles the common pattern of:

  1. Fetching a page of results
  2. Yielding items one by one
  3. Fetching the next page when the current batch is exhausted
  4. Stopping when there are no more pages

The closure should capture any state it needs (e.g., client, owner address).

§Example

let stream = paginate(move |cursor| {
    let client = client.clone();
    async move {
        client.fetch_page(cursor.as_deref()).await
    }
});