ruma_client_api/device/
get_device.rs

1//! `GET /_matrix/client/*/devices/{deviceId}`
2//!
3//! Get a device for authenticated user.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3devicesdeviceid
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedDeviceId,
13    };
14
15    use crate::device::Device;
16
17    const METADATA: Metadata = metadata! {
18        method: GET,
19        rate_limited: false,
20        authentication: AccessToken,
21        history: {
22            1.0 => "/_matrix/client/r0/devices/:device_id",
23            1.1 => "/_matrix/client/v3/devices/:device_id",
24        }
25    };
26
27    /// Request type for the `get_device` endpoint.
28    #[request(error = crate::Error)]
29    pub struct Request {
30        /// The device to retrieve.
31        #[ruma_api(path)]
32        pub device_id: OwnedDeviceId,
33    }
34
35    /// Response type for the `get_device` endpoint.
36    #[response(error = crate::Error)]
37    pub struct Response {
38        /// Information about the device.
39        #[ruma_api(body)]
40        pub device: Device,
41    }
42
43    impl Request {
44        /// Creates a new `Request` with the given device ID.
45        pub fn new(device_id: OwnedDeviceId) -> Self {
46            Self { device_id }
47        }
48    }
49
50    impl Response {
51        /// Creates a new `Response` with the given device.
52        pub fn new(device: Device) -> Self {
53            Self { device }
54        }
55    }
56}