synapse_admin_api/experimental_features/list_features/
v1.rs1use crate::experimental_features::enable_features::v1::ExperimentalFeatures;
4use ruma::{
5 api::{request, response, Metadata},
6 metadata, OwnedUserId,
7};
8use serde::{Deserialize, Serialize};
9
10const METADATA: Metadata = metadata! {
11 method: GET,
12 rate_limited: false,
13 authentication: AccessToken,
14 history: {
15 unstable => "/_synapse/admin/v1/experimental_features/:user_id",
16 }
17};
18
19#[request]
20#[derive(Serialize, Deserialize, PartialEq)]
21pub struct Request {
22 #[ruma_api(path)]
24 pub user_id: OwnedUserId,
25}
26
27#[response]
28#[derive(Serialize, Deserialize, PartialEq)]
29pub struct Response {
30 pub features: ExperimentalFeatures,
32}
33
34impl Request {
35 pub fn new(user_id: OwnedUserId) -> Self {
37 Self { user_id }
38 }
39}
40
41impl Response {
42 pub fn new(features: ExperimentalFeatures) -> Self {
44 Self { features }
45 }
46}
47
48#[test]
49fn test_list_features() {
50 let response = Response {
51 features: ExperimentalFeatures {
52 msc3026: Option::from(false),
53 msc3881: None,
54 msc3967: None,
55 },
56 };
57
58 let json_str = "{\"features\":{\"msc3026\":false}}";
59 let deserialized: Response = serde_json::from_str(json_str).expect("Failed to deserialize");
61 assert_eq!(deserialized, response);
62
63 let serialized = serde_json::to_string(&response).expect("Failed to serialize");
65 assert_eq!(serialized, json_str);
66}