From d14213ab3ed188225e2501a71897116bcbbbaff8 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 29 Jan 2021 15:32:07 +0100 Subject: [PATCH] client-api: Make device::Device non-exhaustive --- ruma-client-api/src/r0/device.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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 } + } +}