jmap_mail_types/backend.rs
1//! Property selector enums and [`jmap_types::JmapObject`] impls for RFC 8621 types.
2//!
3//! These are defined here so that `jmap-mail-server` can use them without
4//! violating the orphan rule (`JmapObject` is foreign but the mail types are
5//! local to this crate).
6
7use jmap_types::{GetObject, JmapObject, PatchObject, QueryObject, SetObject};
8
9// ---------------------------------------------------------------------------
10// Property selector enums (server-side; no serde required)
11// ---------------------------------------------------------------------------
12
13/// Property selector for [`crate::Mailbox`] `/get` and `/set`.
14#[derive(Debug, Clone, PartialEq, Eq, Hash)]
15pub enum MailboxProperty {
16 /// The `id` property (RFC 8621 §2).
17 Id,
18 /// The `name` property (RFC 8621 §2).
19 Name,
20 /// The `parentId` property (RFC 8621 §2).
21 ParentId,
22 /// The `role` property (RFC 8621 §2).
23 Role,
24 /// The `sortOrder` property (RFC 8621 §2).
25 SortOrder,
26 /// The `totalEmails` property (RFC 8621 §2).
27 TotalEmails,
28 /// The `unreadEmails` property (RFC 8621 §2).
29 UnreadEmails,
30 /// The `totalThreads` property (RFC 8621 §2).
31 TotalThreads,
32 /// The `unreadThreads` property (RFC 8621 §2).
33 UnreadThreads,
34 /// The `myRights` property (RFC 8621 §2).
35 MyRights,
36 /// The `isSubscribed` property (RFC 8621 §2).
37 IsSubscribed,
38}
39
40/// Property selector for [`crate::Thread`] `/get`.
41#[derive(Debug, Clone, PartialEq, Eq, Hash)]
42pub enum ThreadProperty {
43 /// The `id` property (RFC 8621 §3).
44 Id,
45 /// The `emailIds` property (RFC 8621 §3).
46 EmailIds,
47}
48
49/// Property selector for [`crate::Email`] `/get` and `/set`.
50#[derive(Debug, Clone, PartialEq, Eq, Hash)]
51pub enum EmailProperty {
52 /// The `id` property (RFC 8621 §4).
53 Id,
54 /// The `blobId` property (RFC 8621 §4).
55 BlobId,
56 /// The `threadId` property (RFC 8621 §4).
57 ThreadId,
58 /// The `mailboxIds` property (RFC 8621 §4).
59 MailboxIds,
60 /// The `keywords` property (RFC 8621 §4).
61 Keywords,
62 /// The `size` property (RFC 8621 §4).
63 Size,
64 /// The `receivedAt` property (RFC 8621 §4).
65 ReceivedAt,
66 /// The `messageId` property (RFC 8621 §4).
67 MessageId,
68 /// The `inReplyTo` property (RFC 8621 §4).
69 InReplyTo,
70 /// The `references` property (RFC 8621 §4).
71 References,
72 /// The `subject` property (RFC 8621 §4).
73 Subject,
74 /// The `from` property (RFC 8621 §4).
75 From,
76 /// The `to` property (RFC 8621 §4).
77 To,
78 /// The `cc` property (RFC 8621 §4).
79 Cc,
80 /// The `bcc` property (RFC 8621 §4).
81 Bcc,
82 /// The `replyTo` property (RFC 8621 §4).
83 ReplyTo,
84 /// The `sender` property (RFC 8621 §4).
85 Sender,
86 /// The `sentAt` property (RFC 8621 §4).
87 SentAt,
88 /// The `hasAttachment` property (RFC 8621 §4).
89 HasAttachment,
90 /// The `preview` property (RFC 8621 §4).
91 Preview,
92 /// The `bodyStructure` property (RFC 8621 §4).
93 BodyStructure,
94 /// The `textBody` property (RFC 8621 §4).
95 TextBody,
96 /// The `htmlBody` property (RFC 8621 §4).
97 HtmlBody,
98 /// The `attachments` property (RFC 8621 §4).
99 Attachments,
100 /// The `bodyValues` property (RFC 8621 §4).
101 BodyValues,
102 /// The `headers` property (RFC 8621 §4).
103 Headers,
104}
105
106/// Property selector for [`crate::Identity`] `/get` and `/set`.
107#[derive(Debug, Clone, PartialEq, Eq, Hash)]
108pub enum IdentityProperty {
109 /// The `id` property (RFC 8621 §6).
110 Id,
111 /// The `name` property (RFC 8621 §6).
112 Name,
113 /// The `email` property (RFC 8621 §6).
114 Email,
115 /// The `replyTo` property (RFC 8621 §6).
116 ReplyTo,
117 /// The `bcc` property (RFC 8621 §6).
118 Bcc,
119 /// The `textSignature` property (RFC 8621 §6).
120 TextSignature,
121 /// The `htmlSignature` property (RFC 8621 §6).
122 HtmlSignature,
123 /// The `mayDelete` property (RFC 8621 §6).
124 MayDelete,
125}
126
127/// Property selector for [`crate::EmailSubmission`] `/get` and `/set`.
128#[derive(Debug, Clone, PartialEq, Eq, Hash)]
129pub enum EmailSubmissionProperty {
130 /// The `id` property (RFC 8621 §7).
131 Id,
132 /// The `identityId` property (RFC 8621 §7).
133 IdentityId,
134 /// The `emailId` property (RFC 8621 §7).
135 EmailId,
136 /// The `threadId` property (RFC 8621 §7).
137 ThreadId,
138 /// The `envelope` property (RFC 8621 §7).
139 Envelope,
140 /// The `sendAt` property (RFC 8621 §7).
141 SendAt,
142 /// The `undoStatus` property (RFC 8621 §7).
143 UndoStatus,
144 /// The `deliveryStatus` property (RFC 8621 §7).
145 DeliveryStatus,
146 /// The `dsnBlobIds` property (RFC 8621 §7).
147 DsnBlobIds,
148 /// The `mdnBlobIds` property (RFC 8621 §7).
149 MdnBlobIds,
150}
151
152/// Property selector for [`crate::VacationResponse`] `/get` and `/set`.
153#[derive(Debug, Clone, PartialEq, Eq, Hash)]
154pub enum VacationResponseProperty {
155 /// The `id` property (RFC 8621 §8).
156 Id,
157 /// The `isEnabled` property (RFC 8621 §8).
158 IsEnabled,
159 /// The `fromDate` property (RFC 8621 §8).
160 FromDate,
161 /// The `toDate` property (RFC 8621 §8).
162 ToDate,
163 /// The `subject` property (RFC 8621 §8).
164 Subject,
165 /// The `textBody` property (RFC 8621 §8).
166 TextBody,
167 /// The `htmlBody` property (RFC 8621 §8).
168 HtmlBody,
169}
170
171/// Property selector for [`crate::SearchSnippet`] `/get`.
172#[derive(Debug, Clone, PartialEq, Eq, Hash)]
173pub enum SearchSnippetProperty {
174 /// The `emailId` property (RFC 8621 §5).
175 EmailId,
176 /// The `subject` property (RFC 8621 §5).
177 Subject,
178 /// The `preview` property (RFC 8621 §5).
179 Preview,
180}
181
182/// Property selector for [`crate::SieveScript`] `/get` and `/set`.
183#[cfg(feature = "sieve")]
184#[derive(Debug, Clone, PartialEq, Eq, Hash)]
185pub enum SieveScriptProperty {
186 /// The `id` property (RFC 9661).
187 Id,
188 /// The `name` property (RFC 9661).
189 Name,
190 /// The `blobId` property (RFC 9661).
191 BlobId,
192 /// The `isActive` property (RFC 9661).
193 IsActive,
194}
195
196// ---------------------------------------------------------------------------
197// JmapObject impls
198// ---------------------------------------------------------------------------
199
200impl JmapObject for crate::Mailbox {
201 const TYPE_NAME: &'static str = "Mailbox";
202 type Property = MailboxProperty;
203}
204
205impl GetObject for crate::Mailbox {}
206
207impl SetObject for crate::Mailbox {
208 type Patch = PatchObject;
209}
210
211impl QueryObject for crate::Mailbox {
212 type Filter = crate::MailboxFilterCondition;
213 type Comparator = serde_json::Value;
214}
215
216impl JmapObject for crate::Thread {
217 const TYPE_NAME: &'static str = "Thread";
218 type Property = ThreadProperty;
219}
220
221impl GetObject for crate::Thread {}
222
223impl JmapObject for crate::Email {
224 const TYPE_NAME: &'static str = "Email";
225 type Property = EmailProperty;
226}
227
228impl GetObject for crate::Email {}
229
230impl SetObject for crate::Email {
231 type Patch = PatchObject;
232}
233
234impl QueryObject for crate::Email {
235 type Filter = crate::EmailFilter;
236 type Comparator = crate::EmailComparator;
237}
238
239impl JmapObject for crate::Identity {
240 const TYPE_NAME: &'static str = "Identity";
241 type Property = IdentityProperty;
242}
243
244impl GetObject for crate::Identity {}
245
246impl SetObject for crate::Identity {
247 type Patch = PatchObject;
248}
249
250impl JmapObject for crate::EmailSubmission {
251 const TYPE_NAME: &'static str = "EmailSubmission";
252 type Property = EmailSubmissionProperty;
253}
254
255impl GetObject for crate::EmailSubmission {}
256
257impl SetObject for crate::EmailSubmission {
258 type Patch = PatchObject;
259}
260
261impl QueryObject for crate::EmailSubmission {
262 type Filter = crate::EmailSubmissionFilter;
263 type Comparator = serde_json::Value;
264}
265
266impl JmapObject for crate::VacationResponse {
267 const TYPE_NAME: &'static str = "VacationResponse";
268 type Property = VacationResponseProperty;
269}
270
271impl GetObject for crate::VacationResponse {}
272
273impl SetObject for crate::VacationResponse {
274 type Patch = PatchObject;
275}
276
277impl JmapObject for crate::SearchSnippet {
278 const TYPE_NAME: &'static str = "SearchSnippet";
279 type Property = SearchSnippetProperty;
280}
281
282#[cfg(feature = "sieve")]
283impl JmapObject for crate::sieve::SieveScript {
284 const TYPE_NAME: &'static str = "SieveScript";
285 type Property = SieveScriptProperty;
286}
287
288#[cfg(feature = "sieve")]
289impl GetObject for crate::sieve::SieveScript {}
290
291#[cfg(feature = "sieve")]
292impl SetObject for crate::sieve::SieveScript {
293 type Patch = PatchObject;
294}