ruma_client_api/rtc/transports.rs
1//! `GET /_matrix/client/*/rtc/transports`
2//!
3//! Discover the RTC transports advertised by the homeserver.
4//!
5//! There are separate modules for the stable and unstable endpoints, because
6//! [MSC4143] was allowed to stabilize with a renamed response field.
7//!
8//! [MSC4143]: https://github.com/matrix-org/matrix-spec-proposals/pull/4143
9
10pub mod msc4143 {
11 //! `/unstable/org.matrix.msc4143/` ([MSC])
12 //!
13 //! [MSC]: https://github.com/matrix-org/matrix-spec-proposals/pull/4143
14
15 use ruma_common::{
16 api::{auth_scheme::AccessToken, request, response},
17 metadata,
18 };
19
20 use crate::rtc::RtcTransport;
21
22 metadata! {
23 method: GET,
24 rate_limited: false,
25 authentication: AccessToken,
26 history: {
27 unstable("org.matrix.msc4143") => "/_matrix/client/unstable/org.matrix.msc4143/rtc/transports",
28 }
29 }
30
31 /// Request type for the `transports` endpoint.
32 #[request]
33 #[derive(Default)]
34 pub struct Request {}
35
36 impl Request {
37 /// Creates a new empty `Request`.
38 pub fn new() -> Self {
39 Self {}
40 }
41 }
42
43 /// Response type for the `transports` endpoint.
44 #[response]
45 #[derive(Default)]
46 pub struct Response {
47 /// The RTC transports advertised by the homeserver.
48 pub rtc_transports: Vec<RtcTransport>,
49 }
50
51 impl Response {
52 /// Creates a `Response` with the given RTC transports.
53 pub fn new(rtc_transports: Vec<RtcTransport>) -> Self {
54 Self { rtc_transports }
55 }
56 }
57}
58
59pub mod v1 {
60 //! `/v1/` ([MSC], not yet documented in spec)
61 //!
62 //! [MSC]: https://github.com/matrix-org/matrix-spec-proposals/pull/4143
63
64 use ruma_common::{
65 api::{auth_scheme::AccessToken, request, response},
66 metadata,
67 };
68
69 use crate::rtc::RtcTransport;
70
71 metadata! {
72 method: GET,
73 rate_limited: false,
74 authentication: AccessToken,
75 history: {
76 stable("org.matrix.msc4143.stable") => "/_matrix/client/v1/rtc/transports",
77 }
78 }
79
80 /// Request type for the `transports` endpoint.
81 #[request]
82 #[derive(Default)]
83 pub struct Request {}
84
85 impl Request {
86 /// Creates a new empty `Request`.
87 pub fn new() -> Self {
88 Self {}
89 }
90 }
91
92 /// Response type for the `transports` endpoint.
93 #[response]
94 #[derive(Default)]
95 pub struct Response {
96 /// The RTC transports advertised by the homeserver.
97 pub transports: Vec<RtcTransport>,
98 }
99
100 impl Response {
101 /// Creates a `Response` with the given RTC transports.
102 pub fn new(transports: Vec<RtcTransport>) -> Self {
103 Self { transports }
104 }
105 }
106}