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