pub struct Paginator<T> { /* private fields */ }Expand description
iterator for paginated api results
this allows iterating through all pages of results automatically.
§Example
use netbox::{Client, ClientConfig};
// let mut paginator = client.dcim().devices().paginate(None)?;
//
// while let Some(page) = paginator.next_page().await? {
// for device in page.results {
// println!("{:?}", device);
// }
// }Implementations§
Source§impl<T> Paginator<T>where
T: DeserializeOwned,
impl<T> Paginator<T>where
T: DeserializeOwned,
Sourcepub async fn next_page(&mut self) -> Result<Option<Page<T>>>
pub async fn next_page(&mut self) -> Result<Option<Page<T>>>
fetch the next page of results
returns Ok(None) when there are no more pages.
Sourcepub async fn collect_all(self) -> Result<Vec<T>>
pub async fn collect_all(self) -> Result<Vec<T>>
collect all results from all pages into a single vector
Warning: This will fetch all pages, which could be slow and memory-intensive for large result sets.
Sourcepub fn limit_pages(self, max_pages: usize) -> LimitedPaginator<T>
pub fn limit_pages(self, max_pages: usize) -> LimitedPaginator<T>
limit the number of pages to fetch
Auto Trait Implementations§
impl<T> !Freeze for Paginator<T>
impl<T> !RefUnwindSafe for Paginator<T>
impl<T> Send for Paginator<T>where
T: Send,
impl<T> Sync for Paginator<T>where
T: Sync,
impl<T> Unpin for Paginator<T>where
T: Unpin,
impl<T> UnsafeUnpin for Paginator<T>
impl<T> !UnwindSafe for Paginator<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more