use ruma_common::{
api::{auth_scheme::NoAccessToken, request, response},
metadata,
};
use serde::{Deserialize, Serialize};
#[cfg(feature = "unstable-msc4143")]
use crate::rtc::RtcTransport;
metadata! {
method: GET,
rate_limited: false,
authentication: NoAccessToken,
path: "/.well-known/matrix/client",
}
#[request]
#[derive(Default)]
pub struct Request {}
#[response]
pub struct Response {
#[serde(rename = "m.homeserver")]
pub homeserver: HomeserverInfo,
#[serde(rename = "m.identity_server", skip_serializing_if = "Option::is_none")]
pub identity_server: Option<IdentityServerInfo>,
#[cfg(feature = "unstable-msc3488")]
#[serde(
rename = "org.matrix.msc3488.tile_server",
alias = "m.tile_server",
skip_serializing_if = "Option::is_none"
)]
pub tile_server: Option<TileServerInfo>,
#[cfg(feature = "unstable-msc4143")]
#[serde(
rename = "org.matrix.msc4143.rtc_foci",
alias = "m.rtc_foci",
default,
skip_serializing_if = "Vec::is_empty"
)]
pub rtc_foci: Vec<RtcTransport>,
}
impl Request {
pub fn new() -> Self {
Self {}
}
}
impl Response {
pub fn new(homeserver: HomeserverInfo) -> Self {
Self {
homeserver,
identity_server: None,
#[cfg(feature = "unstable-msc3488")]
tile_server: None,
#[cfg(feature = "unstable-msc4143")]
rtc_foci: Default::default(),
}
}
}
#[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct HomeserverInfo {
pub base_url: String,
}
impl HomeserverInfo {
pub fn new(base_url: String) -> Self {
Self { base_url }
}
}
#[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct IdentityServerInfo {
pub base_url: String,
}
impl IdentityServerInfo {
pub fn new(base_url: String) -> Self {
Self { base_url }
}
}
#[cfg(feature = "unstable-msc3488")]
#[derive(Clone, Debug, Deserialize, Hash, Serialize, PartialEq, Eq)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct TileServerInfo {
pub map_style_url: String,
}
#[cfg(feature = "unstable-msc3488")]
impl TileServerInfo {
pub fn new(map_style_url: String) -> Self {
Self { map_style_url }
}
}