Struct egg_mode::tweet::DraftTweet[][src]

pub struct DraftTweet {
    pub text: Cow<'static, str>,
    pub in_reply_to: Option<u64>,
    pub auto_populate_reply_metadata: Option<bool>,
    pub exclude_reply_user_ids: Option<Cow<'static, [u64]>>,
    pub attachment_url: Option<Cow<'static, str>>,
    pub coordinates: Option<(f64, f64)>,
    pub display_coordinates: Option<bool>,
    pub place_id: Option<Cow<'static, str>>,
    pub media_ids: Vec<MediaId>,
    pub possibly_sensitive: Option<bool>,
}
Expand description

Represents an in-progress tweet before it is sent.

This is your entry point to posting new tweets to Twitter. To begin, make a new DraftTweet by calling new with your desired status text:

use egg_mode::tweet::DraftTweet;

let draft = DraftTweet::new("This is an example status!");

As-is, the draft won’t do anything until you call send to post it:


draft.send(&token).await.unwrap();

Right now, the options for adding metadata to a post are pretty sparse. See the adaptor functions below to see what metadata can be set. For example, you can use in_reply_to to create a reply-chain like this:

use egg_mode::tweet::DraftTweet;

let draft = DraftTweet::new("I'd like to start a thread here.");
let tweet = draft.send(&token).await.unwrap();

let draft = DraftTweet::new("You see, I have a lot of things to say.")
                       .in_reply_to(tweet.id);
let tweet = draft.send(&token).await.unwrap();

let draft = DraftTweet::new("Thank you for your time.")
                       .in_reply_to(tweet.id);
let tweet = draft.send(&token).await.unwrap();

Fields

text: Cow<'static, str>

The text of the draft tweet.

in_reply_to: Option<u64>

If present, the ID of the tweet this draft is replying to.

auto_populate_reply_metadata: Option<bool>

If present, whether to automatically fill reply mentions from the metadata of the in_reply_to tweet.

exclude_reply_user_ids: Option<Cow<'static, [u64]>>

If present, the list of user IDs to exclude from the automatically-populated metadata pulled when auto_populate_reply_metadata is true.

attachment_url: Option<Cow<'static, str>>

If present, the tweet link to quote or a DM deep link to include in the tweet’s attachment metadata.

Note that if this link is not a tweet link or a DM deep link, Twitter will return an error when the draft is sent.

coordinates: Option<(f64, f64)>

If present, the latitude/longitude coordinates to attach to the draft.

display_coordinates: Option<bool>

If present (and if coordinates is present), indicates whether to display a pin on the exact coordinate when the eventual tweet is displayed.

place_id: Option<Cow<'static, str>>

If present the Place to attach to this draft.

media_ids: Vec<MediaId>

List of media entities associated with tweet.

A tweet can have one video, one GIF, or up to four images attached to it. When attaching them to a tweet, they’re represented by a media ID, given through the upload process. (See the media module for more information on how to upload media.)

DraftTweet treats zeros in this array as if the media were not present.

possibly_sensitive: Option<bool>

States whether the media attached with media_ids should be labeled as “possibly sensitive”, to mask the media by default.

Implementations

Creates a new DraftTweet with the given status text.

Marks this draft tweet as replying to the given status ID.

Note that this will only properly take effect if the user who posted the given status is @mentioned in the status text, or if the given status was posted by the authenticated user.

Tells Twitter whether or not to automatically fill reply mentions from the tweet linked in in_reply_to.

This parameter will have no effect if in_reply_to is absent.

If you set this to true, you can strip out the mentions from the beginning of the tweet text if they were also in the reply mentions of the parent tweet. To remove handles from the list of reply mentions, hand their user IDs to exclude_reply_user_ids.

Tells Twitter to exclude the given list of user IDs from the automatically-populated reply mentions.

This parameter will have no effect if auto_populate_reply_metadata is absent or false.

Note that you cannot use this parameter to remove the author of the parent tweet from the reply list. Twitter will silently ignore the author’s ID in that scenario.

Attaches the given tweet URL or DM deep link to the tweet draft, which lets it be used outside the 280 character text limit.

Note that if this link is not a tweet URL or a DM deep link, then Twitter will return an error when this draft is sent.

Attach a lat/lon coordinate to this tweet, and mark whether a pin should be placed on the exact coordinate when the tweet is displayed.

If coordinates are given through this method and no place_id is attached, Twitter will effectively call place::reverse_geocode with the given coordinate and attach that Place to the eventual tweet.

Location fields will be ignored unless the user has enabled geolocation from their profile.

Attach a Place to this tweet. This field will take precedence over coordinates in terms of what location is displayed with the tweet.

Location fields will be ignored unless the user has enabled geolocation from their profile.

Attaches the given media ID(s) to this tweet. If more than four IDs are in this slice, only the first four will be attached. Note that Twitter will only allow one GIF, one video, or up to four images to be attached to a single tweet.

Note that if this is called multiple times, only the last four IDs will be kept.

Marks the media attached with media_ids as being sensitive, so it can be hidden by default.

Send the assembled tweet as the authenticated user.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

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

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.