ruma_client_api/discovery/
discover_homeserver.rs1use ruma_common::{
11 api::{auth_scheme::NoAccessToken, request, response},
12 metadata,
13};
14use serde::{Deserialize, Serialize};
15
16#[cfg(feature = "unstable-msc4143")]
17use crate::rtc::RtcTransport;
18
19metadata! {
20 method: GET,
21 rate_limited: false,
22 authentication: NoAccessToken,
23 path: "/.well-known/matrix/client",
24}
25
26#[request]
28#[derive(Default)]
29pub struct Request {}
30
31#[response]
33pub struct Response {
34 #[serde(rename = "m.homeserver")]
36 pub homeserver: HomeserverInfo,
37
38 #[serde(rename = "m.identity_server", skip_serializing_if = "Option::is_none")]
40 pub identity_server: Option<IdentityServerInfo>,
41
42 #[cfg(feature = "unstable-msc3488")]
44 #[serde(
45 rename = "org.matrix.msc3488.tile_server",
46 alias = "m.tile_server",
47 skip_serializing_if = "Option::is_none"
48 )]
49 pub tile_server: Option<TileServerInfo>,
50
51 #[cfg(feature = "unstable-msc4143")]
53 #[serde(
54 rename = "org.matrix.msc4143.rtc_foci",
55 alias = "m.rtc_foci",
56 default,
57 skip_serializing_if = "Vec::is_empty"
58 )]
59 pub rtc_foci: Vec<RtcTransport>,
60}
61
62impl Request {
63 pub fn new() -> Self {
65 Self {}
66 }
67}
68
69impl Response {
70 pub fn new(homeserver: HomeserverInfo) -> Self {
72 Self {
73 homeserver,
74 identity_server: None,
75 #[cfg(feature = "unstable-msc3488")]
76 tile_server: None,
77 #[cfg(feature = "unstable-msc4143")]
78 rtc_foci: Default::default(),
79 }
80 }
81}
82
83#[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)]
85#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
86pub struct HomeserverInfo {
87 pub base_url: String,
89}
90
91impl HomeserverInfo {
92 pub fn new(base_url: String) -> Self {
94 Self { base_url }
95 }
96}
97
98#[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)]
100#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
101pub struct IdentityServerInfo {
102 pub base_url: String,
104}
105
106impl IdentityServerInfo {
107 pub fn new(base_url: String) -> Self {
109 Self { base_url }
110 }
111}
112
113#[cfg(feature = "unstable-msc3488")]
115#[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)]
116#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
117pub struct TileServerInfo {
118 pub map_style_url: String,
122}
123
124#[cfg(feature = "unstable-msc3488")]
125impl TileServerInfo {
126 pub fn new(map_style_url: String) -> Self {
128 Self { map_style_url }
129 }
130}