1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Clone)]
8pub struct Config {
9 pub token: String,
11
12 pub client: Option<reqwest::Client>,
15
16 pub ping_interval: f64,
18
19 pub pong_timeout: f64,
21
22 pub reconnect_backoff_max: f64,
24
25 pub max_reconnect_attempts: u32,
27}
28
29impl Default for Config {
30 fn default() -> Self {
31 Self {
32 token: String::new(),
33 client: None,
34 ping_interval: 15.0,
35 pong_timeout: 14.0,
36 reconnect_backoff_max: 32.0,
37 max_reconnect_attempts: 10,
38 }
39 }
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct DeviceRegistration {
45 #[serde(rename = "webSocketUrl")]
47 pub web_socket_url: String,
48
49 #[serde(rename = "url")]
51 pub device_url: String,
52
53 #[serde(rename = "userId")]
55 pub user_id: String,
56
57 #[serde(default)]
59 pub services: HashMap<String, String>,
60
61 #[serde(skip)]
63 pub encryption_service_url: String,
64}
65
66#[derive(Debug, Clone, Default, Serialize, Deserialize)]
68pub struct MercuryActor {
69 #[serde(default)]
70 pub id: String,
71
72 #[serde(rename = "objectType", default)]
73 pub object_type: String,
74
75 #[serde(rename = "emailAddress", default)]
76 pub email_address: Option<String>,
77}
78
79#[derive(Debug, Clone, Default, Serialize, Deserialize)]
81pub struct MercuryObject {
82 #[serde(default)]
83 pub id: String,
84
85 #[serde(rename = "objectType", default)]
86 pub object_type: String,
87
88 #[serde(rename = "displayName", default)]
89 pub display_name: Option<String>,
90
91 #[serde(default)]
92 pub content: Option<String>,
93
94 #[serde(rename = "encryptionKeyUrl", default)]
95 pub encryption_key_url: Option<String>,
96}
97
98#[derive(Debug, Clone, Default, Serialize, Deserialize)]
100pub struct MercuryTarget {
101 #[serde(default)]
102 pub id: String,
103
104 #[serde(rename = "objectType", default)]
105 pub object_type: String,
106
107 #[serde(rename = "encryptionKeyUrl", default)]
108 pub encryption_key_url: Option<String>,
109
110 #[serde(default)]
111 pub tags: Vec<String>,
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize)]
116pub struct MercuryActivity {
117 #[serde(default)]
118 pub id: String,
119
120 #[serde(default)]
121 pub verb: String,
122
123 #[serde(default)]
124 pub actor: MercuryActor,
125
126 #[serde(default)]
127 pub object: MercuryObject,
128
129 #[serde(default)]
130 pub target: MercuryTarget,
131
132 #[serde(default)]
133 pub published: String,
134
135 #[serde(rename = "encryptionKeyUrl", default)]
136 pub encryption_key_url: Option<String>,
137}
138
139#[derive(Debug, Clone)]
141pub struct DecryptedMessage {
142 pub id: String,
144
145 pub room_id: String,
147
148 pub person_id: String,
150
151 pub person_email: String,
153
154 pub text: String,
156
157 pub html: Option<String>,
159
160 pub created: String,
162
163 pub room_type: Option<String>,
165
166 pub raw: MercuryActivity,
168}
169
170#[derive(Debug, Clone)]
172pub struct DeletedMessage {
173 pub message_id: String,
174 pub room_id: String,
175 pub person_id: String,
176}
177
178#[derive(Debug, Clone, Copy, PartialEq, Eq)]
180pub enum ConnectionStatus {
181 Connected,
182 Connecting,
183 Reconnecting,
184 Disconnected,
185}
186
187impl std::fmt::Display for ConnectionStatus {
188 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
189 match self {
190 Self::Connected => write!(f, "connected"),
191 Self::Connecting => write!(f, "connecting"),
192 Self::Reconnecting => write!(f, "reconnecting"),
193 Self::Disconnected => write!(f, "disconnected"),
194 }
195 }
196}
197
198#[derive(Debug, Clone)]
200pub struct HandlerStatus {
201 pub status: ConnectionStatus,
203
204 pub web_socket_open: bool,
206
207 pub kms_initialized: bool,
209
210 pub device_registered: bool,
212
213 pub reconnect_attempt: u32,
215}