pub struct ListIter<T> { /* private fields */ }
Expand description
An iterator that moves objects out of a list.
This struct is created by the into_iter
method on List
.
Upon reaching the end of a page, further pages will be requested and the
iterator will continue yielding items from those pages. As a consequence,
the Item
type of this iterator is a Result
in case those calls fail.
Implementations§
source§impl<T: DeserializeOwned + Send + Sync + Unpin + 'static> ListIter<T>
impl<T: DeserializeOwned + Send + Sync + Unpin + 'static> ListIter<T>
sourcepub async fn next_page(&self) -> Result<Option<Self>>
pub async fn next_page(&self) -> Result<Option<Self>>
Gets a ListIter
for the next page of objects by requesting it from the
API.
§Example
let page_1 = Set::code("inn").await.unwrap().cards().await.unwrap();
let mut page_2 = Box::new(page_1.next_page().await.unwrap().unwrap());
assert_eq!(
page_2
.next()
.await
.unwrap()
.unwrap()
.collector_number
.parse::<usize>()
.unwrap(),
page_1.into_inner().len() + 1
);
sourcepub async fn next(&mut self) -> Option<Result<T>>
pub async fn next(&mut self) -> Option<Result<T>>
Asynchronously returns next element of the stream Will automatically handle pagination Returns None if the Stream is exausted, Result otherwise
sourcepub fn into_stream(self) -> impl Stream<Item = Result<T>> + Unpin
pub fn into_stream(self) -> impl Stream<Item = Result<T>> + Unpin
Creates a Stream from a ListIter
sourcepub fn into_stream_buffered(
self,
buf_factor: usize
) -> impl Stream<Item = Result<T>> + Unpin
pub fn into_stream_buffered( self, buf_factor: usize ) -> impl Stream<Item = Result<T>> + Unpin
Creates a Stream from a ListIter that is buffered by n items
sourcepub fn into_stream_buffered_unordered(
self,
buf_factor: usize
) -> impl Stream<Item = Result<T>> + Unpin
pub fn into_stream_buffered_unordered( self, buf_factor: usize ) -> impl Stream<Item = Result<T>> + Unpin
Creates a Stream from a ListIter that is buffered by n items in a non-deterministic order
sourcepub fn into_inner(self) -> IntoIter<T>
pub fn into_inner(self) -> IntoIter<T>
Extracts the inner vec::IntoIter
that holds this page of data.
Further pages will not be fetched when it gets to the end.
§Examples
let card_names = Card::search("stormcrow").await
.unwrap()
.into_inner()
.map(|c| c.name)
.collect::<Vec<_>>();
assert_eq!(card_names, ["Mindstorm Crown", "Storm Crow"]);