[][src]Struct mammut::page::Page

pub struct Page<'a, T: for<'de> Deserialize<'de>> {
    pub initial_items: Vec<T>,
    // some fields omitted
}

Fields

initial_items: Vec<T>

Initial set of items

Methods

impl<'a, T: for<'de> Deserialize<'de>> Page<'a, T>[src]

pub fn new(mastodon: &'a Mastodon, response: Response) -> Result<Self>[src]

pub fn next_page(&mut self) -> Result<Option<Vec<T>>>[src]

pub fn prev_page(&mut self) -> Result<Option<Vec<T>>>[src]

impl<'a, T: Clone + for<'de> Deserialize<'de>> Page<'a, T>[src]

pub fn items_iter(self) -> impl Iterator<Item = T> + 'a where
    T: 'a, 
[src]

Returns an iterator that provides a stream of Ts

This abstracts away the process of iterating over each item in a page, then making an http call, then iterating over each item in the new page, etc. The iterator provides a stream of Ts, calling self.next_page() when necessary to get more of them, until there are no more items.

Example

use mammut::{Mastodon, Data, StatusesRequest};
let mastodon = Mastodon::from_data(data);
let req = StatusesRequest::new();
let resp = mastodon.statuses("some-id", req)?;
for status in resp.items_iter() {
    // do something with status
}

Auto Trait Implementations

impl<'a, T> Unpin for Page<'a, T> where
    T: Unpin

impl<'a, T> Send for Page<'a, T> where
    T: Send

impl<'a, T> Sync for Page<'a, T> where
    T: Sync

impl<'a, T> !UnwindSafe for Page<'a, T>

impl<'a, T> !RefUnwindSafe for Page<'a, T>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

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

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