pub struct DmConversationObject {
pub dm_conversation: DmConversation,
}Expand description
§Example
use chrono::{DateTime, NaiveDateTime, Utc};
use twitter_archive::convert::date_time_iso_8601;
use twitter_archive::structs::direct_message_group_headers::DmConversationObject;
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#"{{
"dmConversation": {{
"conversationId": "1111-2222",
"messages": [
{{
"messageCreate": {{
"id": "4444444444444444444",
"senderId": "222222222",
"createdAt": "{created_at_string}"
}}
}},
{{
"messageCreate": {{
"id": "3333333333333333333",
"senderId": "111111111",
"createdAt": "{created_at_string}"
}}
}},
{{
"participantsLeave": {{
"userIds": [
"1234",
"9876"
],
"createdAt": "{created_at_string}"
}}
}},
{{
"joinConversation": {{
"initiatingUserId": "111111111",
"participantsSnapshot": [
"222222222",
"111111111"
],
"createdAt": "{created_at_string}"
}}
}}
]
}}
}}"#);
let data: DmConversationObject = serde_json::from_str(&json).unwrap();
// De-serialized properties
assert_eq!(data.dm_conversation.conversation_id, "1111-2222");
assert_eq!(data.dm_conversation.messages.len(), 4);
// Re-serialize is equivalent to original data without pretty printing
assert_eq!(serde_json::to_string_pretty(&data).unwrap(), json);Fields§
§dm_conversation: DmConversation§Example JSON data
{
"dmConversation" : {
"conversationId" : "1111-2222",
"messages" : [
{
"messageCreate" : {
"id" : "4444444444444444444",
"senderId" : "222222222",
"createdAt" : "2023-08-12T17:10:37.000Z"
}
},
{
"messageCreate" : {
"id" : "3333333333333333333",
"senderId" : "111111111",
"createdAt" : "2023-08-12T17:10:37.000Z"
}
},
{
"participantsLeave" : {
"userIds" : [
"1234",
"9876"
],
"createdAt" : "2023-08-12T17:10:37.000Z"
}
},
{
"joinConversation" : {
"initiatingUserId" : "111111111",
"participantsSnapshot" : [
"222222222",
"111111111"
],
"createdAt" : "2023-08-12T17:10:37.000Z"
}
}
]
}
}Trait Implementations§
Source§impl Clone for DmConversationObject
impl Clone for DmConversationObject
Source§fn clone(&self) -> DmConversationObject
fn clone(&self) -> DmConversationObject
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 DmConversationObject
impl Debug for DmConversationObject
Source§impl<'de> Deserialize<'de> for DmConversationObject
impl<'de> Deserialize<'de> for DmConversationObject
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 DmConversationObject
impl Display for DmConversationObject
Auto Trait Implementations§
impl Freeze for DmConversationObject
impl RefUnwindSafe for DmConversationObject
impl Send for DmConversationObject
impl Sync for DmConversationObject
impl Unpin for DmConversationObject
impl UnwindSafe for DmConversationObject
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