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