ruma_client_api/account/
whoami.rs1pub mod v3 {
6    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedDeviceId, OwnedUserId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: GET,
17        rate_limited: true,
18        authentication: AccessToken,
19        history: {
20            1.0 => "/_matrix/client/r0/account/whoami",
21            1.1 => "/_matrix/client/v3/account/whoami",
22        }
23    };
24
25    #[request(error = crate::Error)]
27    #[derive(Default)]
28    pub struct Request {}
29
30    #[response(error = crate::Error)]
32    pub struct Response {
33        pub user_id: OwnedUserId,
35
36        #[serde(skip_serializing_if = "Option::is_none")]
38        pub device_id: Option<OwnedDeviceId>,
39
40        #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
42        pub is_guest: bool,
43    }
44
45    impl Request {
46        pub fn new() -> Self {
48            Self {}
49        }
50    }
51
52    impl Response {
53        pub fn new(user_id: OwnedUserId, is_guest: bool) -> Self {
55            Self { user_id, device_id: None, is_guest }
56        }
57    }
58}