ruma_federation_api/discovery/
get_server_version.rs

1//! `GET /_matrix/federation/*/version`
2//!
3//! Get the implementation name and version of this homeserver.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1version
9
10    use ruma_common::{
11        api::{auth_scheme::NoAuthentication, request, response},
12        metadata,
13    };
14    use serde::{Deserialize, Serialize};
15
16    metadata! {
17        method: GET,
18        rate_limited: false,
19        authentication: NoAuthentication,
20        path: "/_matrix/federation/v1/version",
21    }
22
23    /// Request type for the `get_server_version` endpoint.
24    #[request]
25    #[derive(Default)]
26    pub struct Request {}
27
28    /// Response type for the `get_server_version` endpoint.
29    #[response]
30    #[derive(Default)]
31    pub struct Response {
32        /// Information about the homeserver implementation
33        #[serde(skip_serializing_if = "Option::is_none")]
34        pub server: Option<Server>,
35    }
36
37    impl Request {
38        /// Creates an empty `Request`.
39        pub fn new() -> Self {
40            Self {}
41        }
42    }
43
44    impl Response {
45        /// Creates an empty `Response`.
46        pub fn new() -> Self {
47            Default::default()
48        }
49    }
50
51    /// Arbitrary values that identify this implementation.
52    #[derive(Clone, Debug, Default, Serialize, Deserialize)]
53    #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
54    pub struct Server {
55        /// Arbitrary name that identifies this implementation.
56        #[serde(skip_serializing_if = "Option::is_none")]
57        pub name: Option<String>,
58
59        /// Version of this implementation.
60        ///
61        /// The version format depends on the implementation.
62        #[serde(skip_serializing_if = "Option::is_none")]
63        pub version: Option<String>,
64    }
65
66    impl Server {
67        /// Creates an empty `Server`.
68        pub fn new() -> Self {
69            Default::default()
70        }
71    }
72}