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        OwnedDeviceId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    use crate::device::Device;
17
18    metadata! {
19        method: GET,
20        rate_limited: false,
21        authentication: AccessToken,
22        history: {
23            1.0 => "/_matrix/client/r0/devices/{device_id}",
24            1.1 => "/_matrix/client/v3/devices/{device_id}",
25        }
26    }
27
28    /// Request type for the `get_device` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// The device to retrieve.
32        #[ruma_api(path)]
33        pub device_id: OwnedDeviceId,
34    }
35
36    /// Response type for the `get_device` endpoint.
37    #[response(error = crate::Error)]
38    pub struct Response {
39        /// Information about the device.
40        #[ruma_api(body)]
41        pub device: Device,
42    }
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 }
48        }
49    }
50
51    impl Response {
52        /// Creates a new `Response` with the given device.
53        pub fn new(device: Device) -> Self {
54            Self { device }
55        }
56    }
57}