diff --git a/ruma-client-api/src/r0/device.rs b/ruma-client-api/src/r0/device.rs index ce3a7a1d..a0740ef4 100644 --- a/ruma-client-api/src/r0/device.rs +++ b/ruma-client-api/src/r0/device.rs @@ -13,6 +13,7 @@ pub mod update_device; /// Information about a registered device. #[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)] +#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct Device { /// Device ID pub device_id: DeviceIdBox, @@ -31,3 +32,10 @@ pub struct Device { )] pub last_seen_ts: Option, } + +impl Device { + /// Creates a new `Device` with the given device ID. + pub fn new(device_id: DeviceIdBox) -> Self { + Self { device_id, display_name: None, last_seen_ip: None, last_seen_ts: None } + } +}