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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
pub mod get_location_for_protocol;
pub mod get_location_for_room_alias;
pub mod get_protocol;
pub mod get_protocols;
pub mod get_user_for_protocol;
pub mod get_user_for_user_id;
use std::collections::HashMap;
use ruma_identifiers::{RoomAliasId, UserId};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Protocol {
pub user_fields: Vec<String>,
pub location_fields: Vec<String>,
pub icon: String,
pub field_types: HashMap<String, FieldType>,
pub instances: Vec<ProtocolInstance>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ProtocolInstance {
pub desc: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon: Option<String>,
pub fields: HashMap<String, String>,
pub network_id: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct FieldType {
pub regexp: String,
pub placeholder: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Location {
pub alias: RoomAliasId,
pub protocol: String,
pub fields: HashMap<String, String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct User {
pub userid: UserId,
pub protocol: String,
pub fields: HashMap<String, String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Medium {
Email,
MSISDN,
}