7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | use std::collections::HashMap; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | use matrix_sdk_crypto::Device as InnerDevice; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | /// An E2EE capable Matrix device. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | #[derive(uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | pub struct Device { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | /// The device owner. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | pub user_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | /// The unique ID of the device. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | pub device_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | /// The published public identity keys of the devices |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | /// A map from the key type (e.g. curve25519) to the base64 encoded key. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | pub keys: HashMap<String, String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | /// The supported algorithms of the device. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | pub algorithms: Vec<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | /// The human readable name of the device. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | pub display_name: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | /// A flag indicating if the device has been blocked, blocked devices don't |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | /// receive any room keys from us. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | pub is_blocked: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | /// Is the device locally trusted |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | pub locally_trusted: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | /// Is our cross signing identity trusted and does the identity trust the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | /// device. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | pub cross_signing_trusted: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | /// The first time this device was seen in local timestamp, milliseconds |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | /// since epoch. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | pub first_time_seen_ts: u64, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | /// Whether or not the device is a dehydrated device. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | pub dehydrated: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | impl From<InnerDevice> for Device { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | fn from(d: InnerDevice) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | Device { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | user_id: d.user_id().to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | device_id: d.device_id().to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | keys: d.keys().iter().map(|(k, v)| (k.to_string(), v.to_base64())).collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | algorithms: d.algorithms().iter().map(|a| a.to_string()).collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | display_name: d.display_name().map(|d| d.to_owned()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | is_blocked: d.is_blacklisted(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | locally_trusted: d.is_locally_trusted(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | cross_signing_trusted: d.is_cross_signing_trusted(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | first_time_seen_ts: d.first_time_seen_ts().0.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | dehydrated: d.is_dehydrated(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | } |