matrix_sdk_crypto_ffi/
device.rs1use std::collections::HashMap;
2
3use matrix_sdk_crypto::Device as InnerDevice;
4
5#[derive(uniffi::Record)]
7pub struct Device {
8 pub user_id: String,
10 pub device_id: String,
12 pub keys: HashMap<String, String>,
16 pub algorithms: Vec<String>,
18 pub display_name: Option<String>,
20 pub is_blocked: bool,
23 pub locally_trusted: bool,
25 pub cross_signing_trusted: bool,
28 pub first_time_seen_ts: u64,
31 pub dehydrated: bool,
33}
34
35impl From<InnerDevice> for Device {
36 fn from(d: InnerDevice) -> Self {
37 Device {
38 user_id: d.user_id().to_string(),
39 device_id: d.device_id().to_string(),
40 keys: d.keys().iter().map(|(k, v)| (k.to_string(), v.to_base64())).collect(),
41 algorithms: d.algorithms().iter().map(|a| a.to_string()).collect(),
42 display_name: d.display_name().map(|d| d.to_owned()),
43 is_blocked: d.is_blacklisted(),
44 locally_trusted: d.is_locally_trusted(),
45 cross_signing_trusted: d.is_cross_signing_trusted(),
46 first_time_seen_ts: d.first_time_seen_ts().0.into(),
47 dehydrated: d.is_dehydrated(),
48 }
49 }
50}