Struct scryfall::list::ListIter

source ·
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>

source

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
);
source

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

source

pub fn into_stream(self) -> impl Stream<Item = Result<T>> + Unpin

Creates a Stream from a ListIter

source

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

source

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

source

pub fn size_hint(&self) -> (usize, Option<usize>)

Returns approximate size of Listiter

source

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"]);

Trait Implementations§

source§

impl<T: Clone> Clone for ListIter<T>

source§

fn clone(&self) -> ListIter<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for ListIter<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ListIter<T>

§

impl<T> RefUnwindSafe for ListIter<T>
where T: RefUnwindSafe,

§

impl<T> Send for ListIter<T>
where T: Send,

§

impl<T> Sync for ListIter<T>
where T: Sync,

§

impl<T> Unpin for ListIter<T>
where T: Unpin,

§

impl<T> UnwindSafe for ListIter<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more