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