ruma_client_api/directory/
get_room_visibility.rs

1//! `GET /_matrix/client/*/directory/list/room/{roomId}`
2//!
3//! Get the visibility of a public room on a directory.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3directorylistroomroomid
9
10    use ruma_common::{
11        OwnedRoomId,
12        api::{auth_scheme::NoAuthentication, request, response},
13        metadata,
14    };
15
16    use crate::room::Visibility;
17
18    metadata! {
19        method: GET,
20        rate_limited: false,
21        authentication: NoAuthentication,
22        history: {
23            1.0 => "/_matrix/client/r0/directory/list/room/{room_id}",
24            1.1 => "/_matrix/client/v3/directory/list/room/{room_id}",
25        }
26    }
27
28    /// Request type for the `get_room_visibility` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// The ID of the room of which to request the visibility.
32        #[ruma_api(path)]
33        pub room_id: OwnedRoomId,
34    }
35
36    /// Response type for the `get_room_visibility` endpoint.
37    #[response(error = crate::Error)]
38    pub struct Response {
39        /// Visibility of the room.
40        pub visibility: Visibility,
41    }
42
43    impl Request {
44        /// Creates a new `Request` with the given room ID.
45        pub fn new(room_id: OwnedRoomId) -> Self {
46            Self { room_id }
47        }
48    }
49
50    impl Response {
51        /// Creates a new `Response` with the given visibility.
52        pub fn new(visibility: Visibility) -> Self {
53            Self { visibility }
54        }
55    }
56}