Skip to main content

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, 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    Id,
17    Name,
18    ParentId,
19    Role,
20    SortOrder,
21    TotalEmails,
22    UnreadEmails,
23    TotalThreads,
24    UnreadThreads,
25    MyRights,
26    IsSubscribed,
27}
28
29/// Property selector for [`crate::Thread`] `/get`.
30#[derive(Debug, Clone, PartialEq, Eq, Hash)]
31pub enum ThreadProperty {
32    Id,
33    EmailIds,
34}
35
36/// Property selector for [`crate::Email`] `/get` and `/set`.
37#[derive(Debug, Clone, PartialEq, Eq, Hash)]
38pub enum EmailProperty {
39    Id,
40    BlobId,
41    ThreadId,
42    MailboxIds,
43    Keywords,
44    Size,
45    ReceivedAt,
46    MessageId,
47    InReplyTo,
48    References,
49    Subject,
50    From,
51    To,
52    Cc,
53    Bcc,
54    ReplyTo,
55    Sender,
56    SentAt,
57    HasAttachment,
58    Preview,
59    BodyStructure,
60    TextBody,
61    HtmlBody,
62    Attachments,
63    BodyValues,
64    Headers,
65}
66
67/// Property selector for [`crate::Identity`] `/get` and `/set`.
68#[derive(Debug, Clone, PartialEq, Eq, Hash)]
69pub enum IdentityProperty {
70    Id,
71    Name,
72    Email,
73    ReplyTo,
74    Bcc,
75    TextSignature,
76    HtmlSignature,
77    MayDelete,
78}
79
80/// Property selector for [`crate::EmailSubmission`] `/get` and `/set`.
81#[derive(Debug, Clone, PartialEq, Eq, Hash)]
82pub enum EmailSubmissionProperty {
83    Id,
84    IdentityId,
85    EmailId,
86    ThreadId,
87    Envelope,
88    SendAt,
89    UndoStatus,
90    DeliveryStatus,
91    DsnBlobIds,
92    MdnBlobIds,
93}
94
95/// Property selector for [`crate::VacationResponse`] `/get` and `/set`.
96#[derive(Debug, Clone, PartialEq, Eq, Hash)]
97pub enum VacationResponseProperty {
98    Id,
99    IsEnabled,
100    FromDate,
101    ToDate,
102    Subject,
103    TextBody,
104    HtmlBody,
105}
106
107/// Property selector for [`crate::SearchSnippet`] `/get`.
108#[derive(Debug, Clone, PartialEq, Eq, Hash)]
109pub enum SearchSnippetProperty {
110    EmailId,
111    Subject,
112    Preview,
113}
114
115// ---------------------------------------------------------------------------
116// JmapObject impls
117// ---------------------------------------------------------------------------
118
119impl JmapObject for crate::Mailbox {
120    const TYPE_NAME: &'static str = "Mailbox";
121    type Property = MailboxProperty;
122}
123
124impl GetObject for crate::Mailbox {}
125
126impl SetObject for crate::Mailbox {
127    type Patch = serde_json::Value;
128}
129
130impl QueryObject for crate::Mailbox {
131    type Filter = crate::MailboxFilterCondition;
132    type Comparator = serde_json::Value;
133}
134
135impl JmapObject for crate::Thread {
136    const TYPE_NAME: &'static str = "Thread";
137    type Property = ThreadProperty;
138}
139
140impl GetObject for crate::Thread {}
141
142impl JmapObject for crate::Email {
143    const TYPE_NAME: &'static str = "Email";
144    type Property = EmailProperty;
145}
146
147impl GetObject for crate::Email {}
148
149impl SetObject for crate::Email {
150    type Patch = serde_json::Value;
151}
152
153impl QueryObject for crate::Email {
154    type Filter = crate::EmailFilter;
155    type Comparator = crate::EmailComparator;
156}
157
158impl JmapObject for crate::Identity {
159    const TYPE_NAME: &'static str = "Identity";
160    type Property = IdentityProperty;
161}
162
163impl GetObject for crate::Identity {}
164
165impl SetObject for crate::Identity {
166    type Patch = serde_json::Value;
167}
168
169impl JmapObject for crate::EmailSubmission {
170    const TYPE_NAME: &'static str = "EmailSubmission";
171    type Property = EmailSubmissionProperty;
172}
173
174impl GetObject for crate::EmailSubmission {}
175
176impl SetObject for crate::EmailSubmission {
177    type Patch = serde_json::Value;
178}
179
180impl QueryObject for crate::EmailSubmission {
181    type Filter = crate::EmailSubmissionFilter;
182    type Comparator = serde_json::Value;
183}
184
185impl JmapObject for crate::VacationResponse {
186    const TYPE_NAME: &'static str = "VacationResponse";
187    type Property = VacationResponseProperty;
188}
189
190impl GetObject for crate::VacationResponse {}
191
192impl SetObject for crate::VacationResponse {
193    type Patch = serde_json::Value;
194}
195
196impl JmapObject for crate::SearchSnippet {
197    const TYPE_NAME: &'static str = "SearchSnippet";
198    type Property = SearchSnippetProperty;
199}