ruma_client_api/device/
update_device.rs

1//! `PUT /_matrix/client/*/devices/{deviceId}`
2//!
3//! Update metadata for a device.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3devicesdeviceid
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedDeviceId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: PUT,
17        rate_limited: false,
18        authentication: AccessToken,
19        history: {
20            1.0 => "/_matrix/client/r0/devices/:device_id",
21            1.1 => "/_matrix/client/v3/devices/:device_id",
22        }
23    };
24
25    /// Request type for the `update_device` endpoint.
26    #[request(error = crate::Error)]
27    pub struct Request {
28        /// The device to update.
29        #[ruma_api(path)]
30        pub device_id: OwnedDeviceId,
31
32        /// The new display name for this device.
33        ///
34        /// If this is `None`, the display name won't be changed.
35        #[serde(skip_serializing_if = "Option::is_none")]
36        pub display_name: Option<String>,
37    }
38
39    /// Response type for the `update_device` endpoint.
40    #[response(error = crate::Error)]
41    #[derive(Default)]
42    pub struct Response {}
43
44    impl Request {
45        /// Creates a new `Request` with the given device ID.
46        pub fn new(device_id: OwnedDeviceId) -> Self {
47            Self { device_id, display_name: None }
48        }
49    }
50
51    impl Response {
52        /// Creates an empty `Response`.
53        pub fn new() -> Self {
54            Self {}
55        }
56    }
57}