1use super::{Capabilities, Deserialize, MessageCryptoStatus, Serialize, ServerConfig};
4
5#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
6#[serde(rename_all = "camelCase")]
7pub struct MessageThread {
8 pub uid: u32,
9 pub children: Vec<MessageThread>,
10}
11
12#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
13#[serde(rename_all = "camelCase")]
14pub struct SyncResult {
15 pub mailbox: String,
16 pub uid_validity: Option<u64>,
17 pub uid_next: Option<u64>,
18 pub highest_mod_seq: Option<u64>,
19 pub requires_full_resync: bool,
20 pub new_uids: Vec<u32>,
21 pub changed_uids: Vec<u32>,
22 pub vanished_uids: Vec<u32>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
26#[serde(rename_all = "camelCase")]
27pub struct ProviderPreset {
28 pub provider: String,
29 pub domains: Vec<String>,
30 pub imap: ServerConfig,
31 pub smtp: ServerConfig,
32 pub auth_notes: String,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
36#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
37pub enum ProviderDiscoverySource {
38 BuiltInPreset,
39 ThunderbirdAutoconfig,
40 ThunderbirdIspdb,
41 DnsSrv,
42 HostProbe,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
46#[serde(rename_all = "camelCase")]
47pub struct ProviderDiscovery {
48 pub provider: String,
49 pub domains: Vec<String>,
50 pub imap: ServerConfig,
51 pub smtp: ServerConfig,
52 pub auth_notes: String,
53 pub source: ProviderDiscoverySource,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
57#[serde(rename_all = "camelCase")]
58pub struct ImapCapabilities {
59 pub imap4rev1: bool,
60 pub imap4rev2: bool,
61 pub starttls: bool,
62 pub login_disabled: bool,
63 pub idle: bool,
64 pub namespace: bool,
65 pub quota: bool,
66 pub sort: bool,
67 pub thread: bool,
68 pub unselect: bool,
69 pub condstore: bool,
70 pub qresync: bool,
71 pub move_ext: bool,
72 pub uidplus: bool,
73 pub literal_plus: bool,
74 pub literal_minus: bool,
75 pub enable: bool,
76 pub compress_deflate: bool,
77 pub auth_plain: bool,
78 pub auth_login: bool,
79 pub auth_xoauth2: bool,
80 pub auth_oauthbearer: bool,
81}
82
83impl From<&Capabilities> for ImapCapabilities {
84 fn from(capabilities: &Capabilities) -> Self {
85 Self {
86 imap4rev1: capabilities.imap4rev1,
87 imap4rev2: capabilities.imap4rev2,
88 starttls: capabilities.starttls,
89 login_disabled: capabilities.login_disabled,
90 idle: capabilities.idle,
91 namespace: capabilities.namespace,
92 quota: capabilities.quota,
93 sort: capabilities.sort,
94 thread: capabilities.thread,
95 unselect: capabilities.unselect,
96 condstore: capabilities.condstore,
97 qresync: capabilities.qresync,
98 move_ext: capabilities.move_ext,
99 uidplus: capabilities.uidplus,
100 literal_plus: capabilities.literal_plus,
101 literal_minus: capabilities.literal_minus,
102 enable: capabilities.enable,
103 compress_deflate: capabilities.compress_deflate,
104 auth_plain: capabilities.auth_plain,
105 auth_login: capabilities.auth_login,
106 auth_xoauth2: capabilities.auth_xoauth2,
107 auth_oauthbearer: capabilities.auth_oauthbearer,
108 }
109 }
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
113#[serde(rename_all = "camelCase")]
114pub struct MailboxInfo {
115 pub name: String,
116 pub raw: String,
117 pub delimiter: Option<String>,
118 pub attributes: Vec<String>,
119 pub special_use: Option<SpecialUse>,
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
123#[serde(rename_all = "camelCase")]
124pub struct SpecialFolders {
125 pub inbox: Option<String>,
126 pub sent: Option<String>,
127 pub drafts: Option<String>,
128 pub trash: Option<String>,
129 pub archive: Option<String>,
130 pub junk: Option<String>,
131}
132
133#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
134#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
135pub enum SpecialUse {
136 Inbox,
137 Sent,
138 Drafts,
139 Trash,
140 Archive,
141 Junk,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
145#[serde(rename_all = "camelCase")]
146pub struct MailboxStatus {
147 pub mailbox: String,
148 pub read_only: bool,
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
152#[serde(rename_all = "camelCase")]
153pub struct MailboxStats {
154 pub mailbox: String,
155 pub messages: Option<u64>,
156 pub recent: Option<u64>,
157 pub uid_next: Option<u64>,
158 pub uid_validity: Option<u64>,
159 pub unseen: Option<u64>,
160 pub highest_mod_seq: Option<u64>,
161 pub raw: String,
162}
163
164#[derive(Debug, Serialize, PartialEq, Eq)]
165#[serde(rename_all = "camelCase")]
166pub struct MailboxQuota {
167 pub mailbox: String,
168 pub roots: Vec<String>,
169 pub resources: Vec<QuotaResource>,
170 pub raw: String,
171}
172
173#[derive(Debug, Serialize, PartialEq, Eq)]
174#[serde(rename_all = "camelCase")]
175pub struct QuotaResource {
176 pub root: String,
177 pub name: String,
178 pub usage: u64,
179 pub limit: u64,
180}
181
182#[derive(Debug, Serialize, PartialEq, Eq)]
183#[serde(rename_all = "camelCase")]
184pub struct ImapNamespace {
185 pub personal: Vec<NamespaceEntry>,
186 pub other_users: Vec<NamespaceEntry>,
187 pub shared: Vec<NamespaceEntry>,
188 pub raw: String,
189}
190
191#[derive(Debug, Serialize, PartialEq, Eq)]
192#[serde(rename_all = "camelCase")]
193pub struct NamespaceEntry {
194 pub prefix: String,
195 pub delimiter: Option<String>,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
199#[serde(rename_all = "camelCase")]
200pub struct MessageSummary {
201 pub seq: u32,
202 pub uid: Option<u32>,
203 pub flags: Vec<String>,
204 pub seen: bool,
205 pub answered: bool,
206 pub flagged: bool,
207 pub deleted: bool,
208 pub draft: bool,
209 pub size: Option<u32>,
210 pub internal_date: Option<String>,
211 pub subject: Option<String>,
212 pub from: Option<String>,
213 pub to: Vec<String>,
214 pub cc: Vec<String>,
215 pub reply_to: Vec<String>,
216 pub message_id: Option<String>,
217 pub headers: Vec<MessageHeader>,
218 pub list_unsubscribe: Vec<String>,
219 pub list_unsubscribe_post: Option<String>,
220 pub date: Option<String>,
221 pub preview: Option<String>,
222 pub attachment_count: usize,
223 pub crypto: MessageCryptoStatus,
224}
225
226#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
227#[serde(rename_all = "camelCase")]
228pub struct MessageHeader {
229 pub name: String,
230 pub value: String,
231}
232
233#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
234#[serde(rename_all = "camelCase")]
235pub struct MessageBody {
236 pub uid: u32,
237 pub subject: Option<String>,
238 pub from: Option<String>,
239 pub to: Vec<String>,
240 pub cc: Vec<String>,
241 pub reply_to: Vec<String>,
242 pub message_id: Option<String>,
243 pub in_reply_to: Vec<String>,
244 pub references: Vec<String>,
245 pub headers: Vec<MessageHeader>,
246 pub list_unsubscribe: Vec<String>,
247 pub list_unsubscribe_post: Option<String>,
248 pub date: Option<String>,
249 pub text: Option<String>,
250 pub html: Option<String>,
251 pub text_parts: Vec<String>,
252 pub html_parts: Vec<String>,
253 pub attachments: Vec<AttachmentInfo>,
254 pub crypto: MessageCryptoStatus,
255 pub raw: String,
256}
257
258#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
259#[serde(rename_all = "camelCase")]
260pub struct AttachmentInfo {
261 pub index: usize,
262 pub filename: Option<String>,
263 pub content_type: Option<String>,
264 pub content_id: Option<String>,
265 pub size: usize,
266 pub inline: bool,
267}
268
269#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
270#[serde(rename_all = "camelCase")]
271pub struct AttachmentData {
272 pub uid: u32,
273 pub index: usize,
274 pub filename: Option<String>,
275 pub content_type: Option<String>,
276 pub content_id: Option<String>,
277 pub size: usize,
278 pub inline: bool,
279 pub base64: String,
280}
281
282#[derive(Debug, Serialize)]
283#[serde(rename_all = "camelCase")]
284pub struct AttachmentChunk {
285 pub uid: u32,
286 pub index: usize,
287 pub filename: Option<String>,
288 pub content_type: Option<String>,
289 pub content_id: Option<String>,
290 pub size: usize,
291 pub inline: bool,
292 pub offset: usize,
293 pub length: usize,
294 pub eof: bool,
295 pub base64: String,
296}
297
298#[derive(Debug, Serialize)]
299#[serde(rename_all = "camelCase")]
300pub struct MailboxChanges {
301 pub mailbox: String,
302 pub timed_out: bool,
303 pub events: Vec<MailboxChangeEvent>,
304}
305
306#[derive(Debug, Serialize)]
307#[serde(rename_all = "camelCase")]
308pub struct MailboxChangeEvent {
309 pub kind: MailboxChangeKind,
310 pub raw: String,
311}
312
313#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
314#[serde(rename_all = "camelCase")]
315pub struct CopyResult {
316 pub target_mailbox: String,
317 pub copied: bool,
318 pub response: String,
319}
320
321#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
322#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
323pub enum MailboxChangeKind {
324 Exists,
325 Expunge,
326 Fetch,
327 Recent,
328 Other,
329}
330
331#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
332#[serde(rename_all = "camelCase")]
333pub struct SendResult {
334 pub accepted: bool,
335 pub response: String,
336}
337
338#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
339#[serde(rename_all = "camelCase")]
340pub struct SendAndSaveResult {
341 pub accepted: bool,
342 pub smtp_response: String,
343 pub sent_mailbox: String,
344 pub appended: bool,
345 pub append_response: String,
346}
347
348#[derive(Debug, Serialize)]
349#[serde(rename_all = "camelCase")]
350pub struct SaveDraftResult {
351 pub mailbox: String,
352 pub appended: bool,
353 pub response: String,
354}