1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use ruma_api::ruma_api;
use serde::{Deserialize, Serialize};
ruma_api! {
metadata {
description: "Gets the homeserver's supported login types to authenticate users. Clients should pick one of these and supply it as the type when logging in.",
method: GET,
name: "get_login_types",
path: "/_matrix/client/r0/login",
rate_limited: true,
requires_authentication: false,
}
request {}
response {
pub flows: Vec<LoginType>
}
error: crate::Error
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum LoginType {
#[serde(rename = "m.login.password")]
Password,
#[serde(rename = "m.login.token")]
Token,
}
#[cfg(test)]
mod tests {
use super::LoginType;
#[test]
fn deserialize_login_type() {
assert_eq!(
serde_json::from_str::<LoginType>(r#" {"type": "m.login.password"} "#).unwrap(),
LoginType::Password,
);
}
}