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 api::{request, response, Metadata},
12 metadata, OwnedRoomId,
13 };
14
15 use crate::room::Visibility;
16
17 const METADATA: Metadata = metadata! {
18 method: GET,
19 rate_limited: false,
20 authentication: None,
21 history: {
22 1.0 => "/_matrix/client/r0/directory/list/room/:room_id",
23 1.1 => "/_matrix/client/v3/directory/list/room/:room_id",
24 }
25 };
26
27 /// Request type for the `get_room_visibility` endpoint.
28 #[request(error = crate::Error)]
29 pub struct Request {
30 /// The ID of the room of which to request the visibility.
31 #[ruma_api(path)]
32 pub room_id: OwnedRoomId,
33 }
34
35 /// Response type for the `get_room_visibility` endpoint.
36 #[response(error = crate::Error)]
37 pub struct Response {
38 /// Visibility of the room.
39 pub visibility: Visibility,
40 }
41
42 impl Request {
43 /// Creates a new `Request` with the given room ID.
44 pub fn new(room_id: OwnedRoomId) -> Self {
45 Self { room_id }
46 }
47 }
48
49 impl Response {
50 /// Creates a new `Response` with the given visibility.
51 pub fn new(visibility: Visibility) -> Self {
52 Self { visibility }
53 }
54 }
55}