Skip to main content

jmap_contacts_types/
backend.rs

1//! Property selector enums and [`jmap_types::JmapObject`] impls for JMAP
2//! Contacts types.
3//!
4//! These are defined here so that `jmap-contacts-server` can use them without
5//! violating the orphan rule (`JmapObject` is foreign but the contacts types
6//! are local to this crate).
7//!
8//! `AddressBook` does **not** implement [`QueryObject`] because
9//! RFC 9610 does not define `AddressBook/query` or
10//! `AddressBook/queryChanges`.
11
12use jmap_types::{GetObject, JmapObject, PatchObject, QueryObject, SetObject};
13
14// ---------------------------------------------------------------------------
15// Property selector enums (server-side; no serde required)
16// ---------------------------------------------------------------------------
17
18/// Property selector for [`crate::AddressBook`] `/get` and `/set`.
19#[derive(Debug, Clone, PartialEq, Eq, Hash)]
20#[non_exhaustive]
21pub enum AddressBookProperty {
22    /// The `id` property (RFC 9610 §2).
23    Id,
24    /// The `name` property (RFC 9610 §2).
25    Name,
26    /// The `description` property (RFC 9610 §2).
27    Description,
28    /// The `sortOrder` property (RFC 9610 §2).
29    SortOrder,
30    /// The `isDefault` property (RFC 9610 §2).
31    IsDefault,
32    /// The `isSubscribed` property (RFC 9610 §2).
33    IsSubscribed,
34    /// The `shareWith` property (RFC 9610 §2).
35    ShareWith,
36    /// The `myRights` property (RFC 9610 §2).
37    MyRights,
38}
39
40/// Property selector for [`crate::ContactCard`] `/get`, `/set`, and `/query`.
41#[derive(Debug, Clone, PartialEq, Eq, Hash)]
42#[non_exhaustive]
43pub enum ContactCardProperty {
44    /// The `id` property (RFC 9610 §3; JMAP addition).
45    Id,
46    /// The `addressBookIds` property (RFC 9610 §3; JMAP addition).
47    AddressBookIds,
48    /// The `version` property (RFC 9553 §2.1 Metadata).
49    Version,
50    /// The `created` property (RFC 9553 §2.1 Metadata).
51    Created,
52    /// The `kind` property (RFC 9553 §2.1 Metadata).
53    Kind,
54    /// The `language` property (RFC 9553 §2.1 Metadata).
55    Language,
56    /// The `members` property (RFC 9553 §2.1 Metadata).
57    Members,
58    /// The `prodId` property (RFC 9553 §2.1 Metadata).
59    ProdId,
60    /// The `relatedTo` property (RFC 9553 §2.1 Metadata).
61    RelatedTo,
62    /// The `uid` property (RFC 9553 §2.1 Metadata).
63    Uid,
64    /// The `updated` property (RFC 9553 §2.1 Metadata).
65    Updated,
66    /// The `name` property (RFC 9553 §2.2 Name and Organization).
67    Name,
68    /// The `nicknames` property (RFC 9553 §2.2 Name and Organization).
69    Nicknames,
70    /// The `organizations` property (RFC 9553 §2.2 Name and Organization).
71    Organizations,
72    /// The `speakToAs` property (RFC 9553 §2.2 Name and Organization).
73    SpeakToAs,
74    /// The `titles` property (RFC 9553 §2.2 Name and Organization).
75    Titles,
76    /// The `emails` property (RFC 9553 §2.3 Contact).
77    Emails,
78    /// The `onlineServices` property (RFC 9553 §2.3 Contact).
79    OnlineServices,
80    /// The `phones` property (RFC 9553 §2.3 Contact).
81    Phones,
82    /// The `preferredLanguages` property (RFC 9553 §2.3 Contact).
83    PreferredLanguages,
84    /// The `calendars` property (RFC 9553 §2.4 Calendaring).
85    Calendars,
86    /// The `schedulingAddresses` property (RFC 9553 §2.4 Calendaring).
87    SchedulingAddresses,
88    /// The `addresses` property (RFC 9553 §2.5 Address).
89    Addresses,
90    /// The `cryptoKeys` property (RFC 9553 §2.6 Resources).
91    CryptoKeys,
92    /// The `directories` property (RFC 9553 §2.6 Resources).
93    Directories,
94    /// The `links` property (RFC 9553 §2.6 Resources).
95    Links,
96    /// The `media` property (RFC 9553 §2.6 Resources).
97    Media,
98    /// The `localizations` property (RFC 9553 §2.7 Multilingual).
99    Localizations,
100    /// The `anniversaries` property (RFC 9553 §2.8 Additional).
101    Anniversaries,
102    /// The `keywords` property (RFC 9553 §2.8 Additional).
103    Keywords,
104    /// The `notes` property (RFC 9553 §2.8 Additional).
105    Notes,
106    /// The `personalInfo` property (RFC 9553 §2.8 Additional).
107    PersonalInfo,
108}
109
110// ---------------------------------------------------------------------------
111// JmapObject impls
112// ---------------------------------------------------------------------------
113
114impl JmapObject for crate::AddressBook {
115    const TYPE_NAME: &'static str = "AddressBook";
116    type Property = AddressBookProperty;
117}
118
119impl GetObject for crate::AddressBook {}
120
121impl SetObject for crate::AddressBook {
122    type Patch = PatchObject;
123}
124
125// AddressBook does NOT implement QueryObject — spec has no AddressBook/query.
126
127impl JmapObject for crate::ContactCard {
128    const TYPE_NAME: &'static str = "ContactCard";
129    type Property = ContactCardProperty;
130}
131
132impl GetObject for crate::ContactCard {}
133
134impl SetObject for crate::ContactCard {
135    type Patch = PatchObject;
136}
137
138impl QueryObject for crate::ContactCard {
139    type Filter = crate::ContactCardFilterCondition;
140    type Comparator = crate::ContactCardComparator;
141}