ruma_client_api/membership/
joined_rooms.rs

1//! `GET /_matrix/client/*/joined_rooms`
2//!
3//! Get a list of the user's current rooms.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3joined_rooms
9
10    use ruma_common::{
11        OwnedRoomId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: GET,
18        rate_limited: false,
19        authentication: AccessToken,
20        history: {
21            1.0 => "/_matrix/client/r0/joined_rooms",
22            1.1 => "/_matrix/client/v3/joined_rooms",
23        }
24    }
25
26    /// Request type for the `joined_rooms` endpoint.
27    #[request(error = crate::Error)]
28    #[derive(Default)]
29    pub struct Request {}
30
31    /// Response type for the `joined_rooms` endpoint.
32    #[response(error = crate::Error)]
33    pub struct Response {
34        /// A list of the rooms the user is in, i.e. the ID of each room in
35        /// which the user has joined membership.
36        pub joined_rooms: Vec<OwnedRoomId>,
37    }
38
39    impl Request {
40        /// Creates an empty `Request`.
41        pub fn new() -> Self {
42            Self {}
43        }
44    }
45
46    impl Response {
47        /// Creates a new `Response` with the given joined rooms.
48        pub fn new(joined_rooms: Vec<OwnedRoomId>) -> Self {
49            Self { joined_rooms }
50        }
51    }
52}