[−][src]Struct egg_mode::tweet::DraftTweet
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.
Methods
impl DraftTweet
[src]
pub fn new<S: Into<Cow<'static, str>>>(text: S) -> Self
[src]
Creates a new DraftTweet
with the given status text.
pub fn in_reply_to(self, in_reply_to: u64) -> Self
[src]
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.
pub fn auto_populate_reply_metadata(self, auto_populate: bool) -> Self
[src]
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
.
pub fn exclude_reply_user_ids<V: Into<Cow<'static, [u64]>>>(
self,
user_ids: V
) -> Self
[src]
self,
user_ids: V
) -> Self
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.
pub fn attachment_url<S: Into<Cow<'static, str>>>(self, url: S) -> Self
[src]
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.
pub fn coordinates(self, latitude: f64, longitude: f64, display: bool) -> Self
[src]
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.
pub fn place_id<S: Into<Cow<'static, str>>>(self, place_id: S) -> Self
[src]
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.
pub fn add_media(&mut self, media_id: MediaId)
[src]
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.
pub fn possibly_sensitive(self, sensitive: bool) -> Self
[src]
Marks the media attached with media_ids
as being sensitive, so it can be hidden by
default.
pub async fn send<'_, '_>(&'_ self, token: &'_ Token) -> Result<Response<Tweet>>
[src]
Send the assembled tweet as the authenticated user.
Trait Implementations
impl Clone for DraftTweet
[src]
fn clone(&self) -> DraftTweet
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for DraftTweet
[src]
Auto Trait Implementations
impl RefUnwindSafe for DraftTweet
impl Send for DraftTweet
impl Sync for DraftTweet
impl Unpin for DraftTweet
impl UnwindSafe for DraftTweet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,