jmap_metadata_types/backend.rs
1//! Property selector enum and [`jmap_types`] trait impls for [`crate::Metadata`].
2//!
3//! Defined here so `jmap-metadata-server` can use them without violating the
4//! orphan rule (`JmapObject` is foreign; `Metadata` is local to this crate).
5
6use jmap_types::{GetObject, JmapObject, PatchObject, QueryObject, SetObject};
7
8// ---------------------------------------------------------------------------
9// Property selector enum
10// ---------------------------------------------------------------------------
11
12/// Property selector for [`crate::Metadata`] `/get` and `/set`.
13///
14/// Mirrors the common-properties list from
15/// draft-ietf-jmap-metadata-01 §2.2.1 plus the type-specific
16/// [`Metadata`](MetadataProperty::Metadata) variant for IMAP- and
17/// WebDAV-flavour objects. Vendor-specific Annotation properties are
18/// not enumerated here — clients refer to them by their wire string
19/// (e.g. `"acme.example.com:color"`) directly via
20/// [`VendorProperty`](MetadataProperty::VendorProperty).
21#[derive(Debug, Clone, PartialEq, Eq, Hash)]
22#[non_exhaustive]
23pub enum MetadataProperty {
24 /// The `@type` property (draft-ietf-jmap-metadata-01 §2.2.1.1).
25 TypeName,
26 /// The `id` property (draft-ietf-jmap-metadata-01 §2.2.1.2).
27 Id,
28 /// The `relatedType` property (draft-ietf-jmap-metadata-01 §2.2.1.3).
29 RelatedType,
30 /// The `relatedId` property (draft-ietf-jmap-metadata-01 §2.2.1.4).
31 RelatedId,
32 /// The `isPrivate` property (draft-ietf-jmap-metadata-01 §2.2.1.5).
33 IsPrivate,
34 /// The `metadata` property carried by
35 /// [`crate::ImapMetadata`] (§2.2.2.1) and [`crate::WebDavMetadata`]
36 /// (§2.2.3.1).
37 Metadata,
38 /// A vendor-specific Annotation property (§2.2.1.6). The inner string
39 /// is the domain-prefixed wire key (e.g. `"acme.example.com:color"`).
40 VendorProperty(String),
41}
42
43// ---------------------------------------------------------------------------
44// JmapObject / marker trait impls
45// ---------------------------------------------------------------------------
46
47impl JmapObject for crate::Metadata {
48 const TYPE_NAME: &'static str = "Metadata";
49 type Property = MetadataProperty;
50}
51
52impl GetObject for crate::Metadata {}
53
54impl SetObject for crate::Metadata {
55 type Patch = PatchObject;
56}
57
58impl QueryObject for crate::Metadata {
59 type Filter = crate::MetadataFilterCondition;
60 type Comparator = serde_json::Value;
61}