pub struct DeviceMetadata {
pub user_agent: String,
pub registration_token: String,
pub identity_key: String,
pub created_at: DateTime<Utc>,
pub device_id: String,
}Expand description
§Example
use chrono::{DateTime, NaiveDateTime, Utc};
use twitter_archive::convert::date_time_iso_8601;
use twitter_archive::structs::key_registry::DeviceMetadata;
let created_at_string = "2023-05-30T13:31:42.908Z";
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#"{{
"userAgent": "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/102.0",
"registrationToken": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"identityKey": "DEADBEEF",
"createdAt": "{created_at_string}",
"deviceId": "xxxxxxxx-111a-0000-abcd-333333333333"
}}"#);
let data: DeviceMetadata = serde_json::from_str(&json).unwrap();
// De-serialized properties
assert_eq!(data.user_agent, "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/102.0");
assert_eq!(data.registration_token, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
assert_eq!(data.identity_key, "DEADBEEF");
assert_eq!(data.created_at, created_at_date_time);
assert_eq!(data.device_id, "xxxxxxxx-111a-0000-abcd-333333333333");
// Re-serialize is equivalent to original data
assert_eq!(serde_json::to_string_pretty(&data).unwrap(), json);Fields§
§user_agent: String§Example JSON data
{ "userAgent": "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Firefox/102.0" }registration_token: String§Example JSON data
{ "registrationToken": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }identity_key: String§Example JSON data
{ "identityKey": "DEADBEEF" }created_at: DateTime<Utc>§Example JSON data
{ "createdAt": "2023-05-30T13:31:42.908Z" }device_id: String§Example JSON data
{ "deviceId": "xxxxxxxx-111a-0000-abcd-333333333333" }Trait Implementations§
Source§impl Clone for DeviceMetadata
impl Clone for DeviceMetadata
Source§fn clone(&self) -> DeviceMetadata
fn clone(&self) -> DeviceMetadata
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 DeviceMetadata
impl Debug for DeviceMetadata
Source§impl<'de> Deserialize<'de> for DeviceMetadata
impl<'de> Deserialize<'de> for DeviceMetadata
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 DeviceMetadata
impl Display for DeviceMetadata
Auto Trait Implementations§
impl Freeze for DeviceMetadata
impl RefUnwindSafe for DeviceMetadata
impl Send for DeviceMetadata
impl Sync for DeviceMetadata
impl Unpin for DeviceMetadata
impl UnwindSafe for DeviceMetadata
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