ruma_federation_api/space/get_hierarchy/
unstable.rs1use ruma_common::{
6 api::{path_builder::SinglePath, request, response, Metadata},
7 room::RoomSummary,
8 OwnedRoomId,
9};
10
11use crate::space::SpaceHierarchyParentSummary;
12
13#[request]
15pub struct Request {
16 #[ruma_api(path)]
18 pub room_id: OwnedRoomId,
19
20 #[ruma_api(query)]
24 #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
25 pub suggested_only: bool,
26}
27
28impl Request {
29 pub fn new(room_id: OwnedRoomId) -> Self {
31 Self { room_id, suggested_only: false }
32 }
33}
34
35impl Metadata for Request {
36 const METHOD: http::Method = super::v1::Request::METHOD;
37 const RATE_LIMITED: bool = super::v1::Request::RATE_LIMITED;
38 type Authentication = <super::v1::Request as Metadata>::Authentication;
39 type PathBuilder = <super::v1::Request as Metadata>::PathBuilder;
40 const PATH_BUILDER: Self::PathBuilder =
41 SinglePath::new("/_matrix/federation/unstable/org.matrix.msc2946/hierarchy/{room_id}");
42}
43
44impl From<super::v1::Request> for Request {
45 fn from(value: super::v1::Request) -> Self {
46 let super::v1::Request { room_id, suggested_only } = value;
47 Self { room_id, suggested_only }
48 }
49}
50
51impl From<Request> for super::v1::Request {
52 fn from(value: Request) -> Self {
53 let Request { room_id, suggested_only } = value;
54 Self { room_id, suggested_only }
55 }
56}
57
58#[response]
60pub struct Response {
61 pub children: Vec<RoomSummary>,
65
66 pub inaccessible_children: Vec<OwnedRoomId>,
71
72 pub room: SpaceHierarchyParentSummary,
74}
75
76impl Response {
77 pub fn new(room_summary: SpaceHierarchyParentSummary) -> Self {
79 Self { children: Vec::new(), inaccessible_children: Vec::new(), room: room_summary }
80 }
81}
82
83impl From<super::v1::Response> for Response {
84 fn from(value: super::v1::Response) -> Self {
85 let super::v1::Response { children, inaccessible_children, room } = value;
86 Self { children, inaccessible_children, room }
87 }
88}
89
90impl From<Response> for super::v1::Response {
91 fn from(value: Response) -> Self {
92 let Response { children, inaccessible_children, room } = value;
93 Self { children, inaccessible_children, room }
94 }
95}