[][src]Struct egg_mode::tweet::Timeline

pub struct Timeline<'a> {
    pub count: i32,
    pub max_id: Option<i64>,
    pub min_id: Option<i64>,
    // some fields omitted
}

Helper struct to navigate collections of tweets by requesting tweets older or newer than certain IDs.

Using a Timeline to navigate collections of tweets (like a user's timeline, their list of likes, etc) allows you to efficiently cursor through a collection and only load in tweets you need.

To begin, call a method that returns a Timeline, optionally set the page size, and call start to load the first page of results:

let mut timeline = egg_mode::tweet::home_timeline(&con_token, &access_token)
                               .with_page_size(10);

for tweet in &timeline.start().unwrap().response {
    println!("<@{}> {}", tweet.user.screen_name, tweet.text);
}

If you need to load the next set of tweets, call older, which will automatically update the tweet IDs it tracks:

for tweet in &timeline.older(None).unwrap().response {
    println!("<@{}> {}", tweet.user.screen_name, tweet.text);
}

...and similarly for newer, which operates in a similar fashion.

If you want to start afresh and reload the newest set of tweets again, you can call start again, which will clear the tracked tweet IDs before loading the newest set of tweets. However, if you've been storing these tweets as you go, and already know the newest tweet ID you have on hand, you can load only those tweets you need like this:

let mut timeline = egg_mode::tweet::home_timeline(&con_token, &access_token)
                               .with_page_size(10);

timeline.start().unwrap();

//keep the max_id for later
let reload_id = timeline.max_id.unwrap();

//simulate scrolling down a little bit
timeline.older(None).unwrap();
timeline.older(None).unwrap();

//reload the timeline with only what's new
timeline.reset();
timeline.older(Some(reload_id)).unwrap();

Here, the argument to older means "older than what I just returned, but newer than the given ID". Since we cleared the tracked IDs with reset, that turns into "the newest tweets available that were posted after the given ID". The earlier invocations of older with None do not place a bound on the tweets it loads. newer operates in a similar fashion with its argument, saying "newer than what I just returned, but not newer than this given ID". When called like this, it's possible for these methods to return nothing, which will also clear the Timeline's tracked IDs.

If you want to manually pull tweets between certain IDs, the baseline call function can do that for you. Keep in mind, though, that call doesn't update the min_id or max_id fields, so you'll have to set those yourself if you want to follow up with older or newer.

Fields

The maximum number of tweets to return in a single call. Twitter doesn't guarantee returning exactly this number, as suspended or deleted content is removed after retrieving the initial collection of tweets.

The largest/most recent tweet ID returned in the last call to start, older, or newer.

The smallest/oldest tweet ID returned in the last call to start, older, or newer.

Methods

impl<'a> Timeline<'a>
[src]

Clear the saved IDs on this timeline.

Clear the saved IDs on this timeline, and return the most recent set of tweets.

Return the set of tweets older than the last set pulled, optionally placing a minimum tweet ID to bound with.

Return the set of tweets newer than the last set pulled, optionall placing a maximum tweet ID to bound with.

Return the set of tweets between the IDs given.

Note that the range is not fully inclusive; the tweet ID given by since_id will not be returned, but the tweet ID in max_id will be returned.

If the range of tweets given by the IDs would return more than self.count, the newest set of tweets will be returned.

Helper builder function to set the page size.

Create an instance of Timeline with the given link and tokens.

This is an infrastructure function, not meant to be used from client code. It's not guaranteed to stick around between versions.

Auto Trait Implementations

impl<'a> Send for Timeline<'a>

impl<'a> Sync for Timeline<'a>

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

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

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Typeable for T where
    T: Any
[src]

Get the TypeId of this object.