ruma_client_api/directory/
set_room_visibility.rs

1//! `PUT /_matrix/client/*/directory/list/room/{roomId}`
2//!
3//! Set 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/#put_matrixclientv3directorylistroomroomid
9
10    use ruma_common::{
11        OwnedRoomId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    use crate::room::Visibility;
17
18    metadata! {
19        method: PUT,
20        rate_limited: false,
21        authentication: AccessToken,
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 `set_room_visibility` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// The ID of the room of which to set the visibility.
32        #[ruma_api(path)]
33        pub room_id: OwnedRoomId,
34
35        /// New visibility setting for the room.
36        pub visibility: Visibility,
37    }
38
39    /// Response type for the `set_room_visibility` endpoint.
40    #[response(error = crate::Error)]
41    #[derive(Default)]
42    pub struct Response {}
43
44    impl Request {
45        /// Creates a new `Request` with the given room ID and visibility.
46        pub fn new(room_id: OwnedRoomId, visibility: Visibility) -> Self {
47            Self { room_id, visibility }
48        }
49    }
50
51    impl Response {
52        /// Creates an empty `Response`.
53        pub fn new() -> Self {
54            Self {}
55        }
56    }
57}