pub struct RawDirectMessage {
pub id: u64,
pub created_at: DateTime<Utc>,
pub text: String,
pub entities: DMEntities,
pub attachment: Option<MediaEntity>,
pub ctas: Option<Vec<Cta>>,
pub quick_replies: Option<Vec<QuickReply>>,
pub quick_reply_response: Option<String>,
pub sender_id: u64,
pub source_app_id: Option<String>,
pub recipient_id: u64,
/* private fields */
}Expand description
Minimally-processed form of DirectMessage, prior to changing byte indices or loading
source-app information.
The RawDirectMessage type is used in the process of converting from EventCursor or
SingleEvent into a DirectMessage. They can be directly loaded from a DMEvent struct, but
require a mapping of source-app IDs to convert fully into a DirectMessage. By giving this
mapping to the into_dm function, you can convert a RawDirectMessage into the final
DirectMessage type.
Another way RawDirectMessage differs from DirectMessage is how its entities are stored.
Twitter returns entity information based on codepoint indices, whereas Rust Strings are
indexed using byte indices. egg-mode translates these indices for you when returning a
processed type, but that translation has not occurred when a RawDirectMessage has been
created. The translate_indices function can be used to perform this translation if the
RawDirectMessage is being used directly. The into_dm conversion function also performs this
translation before returning the final DirectMessage.
Fields§
§id: u64Numeric ID for this DM.
created_at: DateTime<Utc>UTC timestamp from when this DM was created.
text: StringThe text of the DM.
entities: DMEntitiesLink, hashtag, and user mention information parsed out of the DM.
attachment: Option<MediaEntity>Media attached to the DM, if present.
ctas: Option<Vec<Cta>>A list of “call to action” buttons, if present.
quick_replies: Option<Vec<QuickReply>>A list of “quick reply” options, if present.
quick_reply_response: Option<String>The metadata associated with the Quick Reply chosen by the sender, if present.
sender_id: u64The ID of the user who sent the DM.
source_app_id: Option<String>The string ID associated with the app used to send the DM, if sent by the authenticated user.
recipient_id: u64The ID of the user who received the DM.
Implementations§
Source§impl RawDirectMessage
impl RawDirectMessage
Sourcepub fn translate_indices(&mut self)
pub fn translate_indices(&mut self)
Translates the codepoint-based indices in this RawDirectMessage’s entities into
byte-based ones.
Note that into_dm also performs this conversion, so if you’re ultimately planning to
convert this into a DirectMessage, you shouldn’t need to call this function directly.
RawDirectMessage tracks whether this translation has occured, so if you need to access
the fields before converting, the final conversion won’t double-translate and leave you
with invalid indices.
Sourcepub fn into_dm(self, apps: &HashMap<String, TweetSource>) -> DirectMessage
pub fn into_dm(self, apps: &HashMap<String, TweetSource>) -> DirectMessage
Converts this RawDirectMessage into a DirectMessage, using the given source-app
mapping.
If the ID given in source_app is not present in the apps mapping, the source-app
information is discarded.
This conversion also calls translate_indices before constructing the DirectMessage.