ruma_client_api/directory/
get_public_rooms_filtered.rs

1//! `POST /_matrix/client/*/publicRooms`
2//!
3//! Get the list of rooms in this homeserver's public directory.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3publicrooms
9
10    use js_int::UInt;
11    use ruma_common::{
12        OwnedServerName,
13        api::{auth_scheme::AccessToken, request, response},
14        directory::{Filter, PublicRoomsChunk, RoomNetwork},
15        metadata,
16    };
17
18    metadata! {
19        method: POST,
20        rate_limited: false,
21        authentication: AccessToken,
22        history: {
23            1.0 => "/_matrix/client/r0/publicRooms",
24            1.1 => "/_matrix/client/v3/publicRooms",
25        }
26    }
27
28    /// Request type for the `get_public_rooms_filtered` endpoint.
29    #[request(error = crate::Error)]
30    #[derive(Default)]
31    pub struct Request {
32        /// The server to fetch the public room lists from.
33        ///
34        /// `None` means the server this request is sent to.
35        #[serde(skip_serializing_if = "Option::is_none")]
36        #[ruma_api(query)]
37        pub server: Option<OwnedServerName>,
38
39        /// Limit for the number of results to return.
40        #[serde(skip_serializing_if = "Option::is_none")]
41        pub limit: Option<UInt>,
42
43        /// Pagination token from a previous request.
44        #[serde(skip_serializing_if = "Option::is_none")]
45        pub since: Option<String>,
46
47        /// Filter to apply to the results.
48        #[serde(default, skip_serializing_if = "Filter::is_empty")]
49        pub filter: Filter,
50
51        /// Network to fetch the public room lists from.
52        #[serde(flatten, skip_serializing_if = "ruma_common::serde::is_default")]
53        pub room_network: RoomNetwork,
54    }
55
56    /// Response type for the `get_public_rooms_filtered` endpoint.
57    #[response(error = crate::Error)]
58    #[derive(Default)]
59    pub struct Response {
60        /// A paginated chunk of public rooms.
61        pub chunk: Vec<PublicRoomsChunk>,
62
63        /// A pagination token for the response.
64        #[serde(skip_serializing_if = "Option::is_none")]
65        pub next_batch: Option<String>,
66
67        /// A pagination token that allows fetching previous results.
68        #[serde(skip_serializing_if = "Option::is_none")]
69        pub prev_batch: Option<String>,
70
71        /// An estimate on the total number of public rooms, if the server has an estimate.
72        #[serde(skip_serializing_if = "Option::is_none")]
73        pub total_room_count_estimate: Option<UInt>,
74    }
75
76    impl Request {
77        /// Creates an empty `Request`.
78        pub fn new() -> Self {
79            Default::default()
80        }
81    }
82
83    impl Response {
84        /// Creates an empty `Response`.
85        pub fn new() -> Self {
86            Default::default()
87        }
88    }
89}