Struct egg_mode::direct::ConversationTimeline [] [src]

pub struct ConversationTimeline<'a> {
    pub last_sent: Option<u64>,
    pub last_received: Option<u64>,
    pub first_sent: Option<u64>,
    pub first_received: Option<u64>,
    pub count: u32,
    pub conversations: DMConversations,
    // some fields omitted
}

Helper struct to load both sent and received direct messages, pre-sorting them into conversations by their recipient.

This timeline loader is meant to get around a limitation of the direct message API endpoints: Twitter only gives endpoints to load all the messages sent by the authenticated user, or all the messages received by the authenticated user. However, the common user interface for DMs is to separate them by the other account in the conversation. This loader is a higher-level wrapper over the direct sent and received calls to achieve this interface without library users having to implement it themselves.

Much like Timeline, simply receiving a ConversationTimeline from conversations does not load any messages on its own. This is to allow setting the page size before loading the first batch of messages.

ConversationTimeline keeps a cache of all the messages its loaded, and updates this during calls to Twitter. Any calls on this timeline that generate a ConversationFuture will take ownership of the ConversationTimeline so that it can update this cache. The Future will return the ConversationTimeline on success. To view the current cache, use the conversations field.

There are two methods to load messages, and they operate by extending the cache by loading messages either older or newer than the extent of the cache.

NOTE: Twitter has different API limitations for sent versus received messages. You can only load the most recent 200 received messages through the public API, but you can load up to 800 sent messages. This can create some strange user-interface if a user has some old conversations, as they can only see their own side of the conversation this way. If you'd like to load as many messages as possible, both API endpoints have a per-call limit of 200. Setting the page size to 200 prior to loading messages allows you to use one function call to load a fairly-complete view of the user's conversations.

Example

let mut conversations = egg_mode::direct::conversations(&token, &handle);

// newest() and oldest() consume the Timeline and give it back on success, so assign it back
// when it's done
conversations = core.run(conversations.newest()).unwrap();

for (id, convo) in &conversations.conversations {
    let user = core.run(egg_mode::user::show(id, &token, &handle)).unwrap();
    println!("Conversation with @{}", user.screen_name);
    for msg in convo {
        println!("<@{}> {}", msg.sender_screen_name, msg.text);
    }
}

Fields

The message ID of the most recent sent message in the current conversation set.

The message ID of the most recent received message in the current conversation set.

The message ID of the oldest sent message in the current conversation set.

The message ID of the oldest received message in the current conversation set.

The number of messages loaded per API call.

The conversation threads that have been loaded so far.

Methods

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

[src]

Builder function to set the number of messages pulled in a single request.

[src]

Load messages newer than the currently-loaded set, or the newset set if no messages have been loaded yet. The complete conversation set can be viewed from the ConversationTimeline after it is finished loading.

[src]

Load messages older than the currently-loaded set, or the newest set if no messages have been loaded. The complete conversation set can be viewed from the ConversationTimeline after it is finished loading.