pub fn paginate<T, F, Fut>(
fetch_page: F,
) -> impl Stream<Item = Result<T, Error>>Expand description
Creates a paginated stream from a fetch function.
This helper handles the common pattern of:
- Fetching a page of results
- Yielding items one by one
- Fetching the next page when the current batch is exhausted
- 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
}
});