pub struct MessageCreate {
pub id: String,
pub sender_id: String,
pub recipient_id: String,
pub created_at: DateTime<Utc>,
}Expand description
§Example
use chrono::{DateTime, NaiveDateTime, Utc};
use twitter_archive::convert::date_time_iso_8601;
use twitter_archive::structs::direct_message_headers::MessageCreate;
let created_at_string = "2023-08-12T17:10:37.000Z";
let created_at_native_time = NaiveDateTime::parse_from_str(&created_at_string, date_time_iso_8601::FORMAT).unwrap();
let created_at_date_time = DateTime::<Utc>::from_naive_utc_and_offset(created_at_native_time, Utc);
let json = format!(r#"{{
"id": "1111111111111111111",
"senderId": "2222",
"recipientId": "1111",
"createdAt": "{created_at_string}"
}}"#);
let data: MessageCreate = serde_json::from_str(&json).unwrap();
// De-serialized properties
assert_eq!(data.id, "1111111111111111111");
assert_eq!(data.sender_id, "2222");
assert_eq!(data.recipient_id, "1111");
assert_eq!(data.created_at, created_at_date_time);
// Re-serialize is equivalent to original data without pretty printing
assert_eq!(serde_json::to_string_pretty(&data).unwrap(), json);Fields§
§id: String§Example JSON data
{ "id": "1111111111111111111" }sender_id: StringID of user sending message
URL formats;
- Desktop:
https://twitter.com/i/user/{sender_id}
Note; does not work if not logged-in. Thanks be to Mr. Musk !-D
§Example JSON data
{ "senderId": "2222" }recipient_id: StringID of user receiving message
URL formats;
- Desktop:
https://twitter.com/i/user/{recipient_id}
Note; does not work if not logged-in. Thanks be to Mr. Musk !-D
§Example JSON data
{ "recipientId": "1111" }created_at: DateTime<Utc>Trait Implementations§
Source§impl Clone for MessageCreate
impl Clone for MessageCreate
Source§fn clone(&self) -> MessageCreate
fn clone(&self) -> MessageCreate
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MessageCreate
impl Debug for MessageCreate
Source§impl<'de> Deserialize<'de> for MessageCreate
impl<'de> Deserialize<'de> for MessageCreate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for MessageCreate
impl Display for MessageCreate
Auto Trait Implementations§
impl Freeze for MessageCreate
impl RefUnwindSafe for MessageCreate
impl Send for MessageCreate
impl Sync for MessageCreate
impl Unpin for MessageCreate
impl UnwindSafe for MessageCreate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more