pub struct DeviceToken {
pub client_application_id: String,
pub token: String,
pub created_at: DateTime<Utc>,
pub last_seen_at: DateTime<Utc>,
pub client_application_name: String,
}Expand description
§Example
use chrono::{DateTime, NaiveDateTime, Utc};
use twitter_archive::convert::date_time_iso_8601;
use twitter_archive::structs::device_token::DeviceToken;
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 last_seen_string = "2023-08-12T17:10:37.000Z";
let last_seen_native_time = NaiveDateTime::parse_from_str(&created_at_string, date_time_iso_8601::FORMAT).unwrap();
let last_seen_date_time = DateTime::<Utc>::from_naive_utc_and_offset(created_at_native_time, Utc);
let json = format!(r#"{{
"clientApplicationId": "1111111",
"token": "DEADBEEF",
"createdAt": "{created_at_string}",
"lastSeenAt": "{last_seen_string}",
"clientApplicationName": "Twitter Web App (Twitter. Inc)"
}}"#);
let data: DeviceToken = serde_json::from_str(&json).unwrap();
// De-serialized properties
assert_eq!(data.client_application_id, "1111111");
assert_eq!(data.token, "DEADBEEF");
assert_eq!(data.created_at, created_at_date_time);
assert_eq!(data.last_seen_at, last_seen_date_time);
assert_eq!(data.client_application_name, "Twitter Web App (Twitter. Inc)");
// Re-serialize is equivalent to original data without pretty printing
assert_eq!(serde_json::to_string_pretty(&data).unwrap(), json);Fields§
§client_application_id: String§Example JSON data
{ "clientApplicationId": "1111111" }token: String§Example JSON data
{ "token": "DEADBEEF" }created_at: DateTime<Utc>§last_seen_at: DateTime<Utc>§client_application_name: String§Example JSON data
{ "clientApplicationName": "Twitter Web App (Twitter. Inc)" }Trait Implementations§
Source§impl Clone for DeviceToken
impl Clone for DeviceToken
Source§fn clone(&self) -> DeviceToken
fn clone(&self) -> DeviceToken
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 DeviceToken
impl Debug for DeviceToken
Source§impl<'de> Deserialize<'de> for DeviceToken
impl<'de> Deserialize<'de> for DeviceToken
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 DeviceToken
impl Display for DeviceToken
Auto Trait Implementations§
impl Freeze for DeviceToken
impl RefUnwindSafe for DeviceToken
impl Send for DeviceToken
impl Sync for DeviceToken
impl Unpin for DeviceToken
impl UnwindSafe for DeviceToken
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