pub struct DmConversation {
pub conversation_id: String,
pub messages: Vec<MessageCreateObject>,
}Expand description
§Example
use chrono::{DateTime, NaiveDateTime, Utc};
use twitter_archive::convert::date_time_iso_8601;
use twitter_archive::structs::direct_message_headers::DmConversation;
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#"{{
"conversationId": "1111-2222",
"messages": [
{{
"messageCreate": {{
"id": "1111111111111111111",
"senderId": "2222",
"recipientId": "1111",
"createdAt": "{created_at_string}"
}}
}}
]
}}"#);
let data: DmConversation = serde_json::from_str(&json).unwrap();
// De-serialized properties
assert_eq!(data.conversation_id, "1111-2222");
assert_eq!(data.messages.len(), 1);
assert_eq!(data.messages[0].message_create.id, "1111111111111111111");
assert_eq!(data.messages[0].message_create.sender_id, "2222");
assert_eq!(data.messages[0].message_create.recipient_id, "1111");
assert_eq!(data.messages[0].message_create.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§
§conversation_id: String§Example JSON data
{ "conversationId": "1111-2222" }messages: Vec<MessageCreateObject>§Example JSON data
{
"messages": [
{
"messageCreate": {
"id": "1111111111111111111",
"senderId": "2222",
"recipientId": "1111",
"createdAt": "2023-08-12T17:10:37.000Z"
}
}
]
}Trait Implementations§
Source§impl Clone for DmConversation
impl Clone for DmConversation
Source§fn clone(&self) -> DmConversation
fn clone(&self) -> DmConversation
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 DmConversation
impl Debug for DmConversation
Source§impl<'de> Deserialize<'de> for DmConversation
impl<'de> Deserialize<'de> for DmConversation
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 DmConversation
impl Display for DmConversation
Auto Trait Implementations§
impl Freeze for DmConversation
impl RefUnwindSafe for DmConversation
impl Send for DmConversation
impl Sync for DmConversation
impl Unpin for DmConversation
impl UnwindSafe for DmConversation
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