Skip to main content

jmap_metadata_types/
capability.rs

1//! draft-ietf-jmap-metadata-02 §1.2.1 — capability registration and
2//! per-data-type metadata info.
3//!
4//! Provides [`DataTypeMetadataInfo`] and the capability URI constant
5//! [`JMAP_METADATA_URI`].
6
7use serde::{Deserialize, Serialize};
8
9/// The JMAP capability URI for the Metadata extension
10/// (draft-ietf-jmap-metadata-02 §1.2.1).
11///
12/// Present as a key in both the session-level `capabilities` object (value:
13/// empty object `{}`) and in each account's `accountCapabilities` object
14/// (value: an object with a `dataTypes` field mapping type names to
15/// [`DataTypeMetadataInfo`]).
16///
17/// The URI is unchanged between -01 and -02.
18pub const JMAP_METADATA_URI: &str = "urn:ietf:params:jmap:metadata";
19
20/// Per-data-type metadata capability advertisement
21/// (draft-ietf-jmap-metadata-02 §1.2.1).
22///
23/// Appears as the value in the `dataTypes` map within the account-level
24/// `urn:ietf:params:jmap:metadata` capability object. A type that does not
25/// appear in `dataTypes` does not gain the `metadata` or `privateMetadata`
26/// properties in that account.
27///
28/// # Wire example (from §6.1)
29///
30/// ```json
31/// {
32///   "namespaces": ["photography"],
33///   "supportsVendorNamespaces": false,
34///   "supportsPrivate": false,
35///   "maxDepth": 3
36/// }
37/// ```
38#[non_exhaustive]
39#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
40#[serde(rename_all = "camelCase")]
41pub struct DataTypeMetadataInfo {
42    /// IANA-registered metadata namespace names supported on this data type
43    /// (§1.2.1). Each value is a registered name (US-ASCII letters, digits,
44    /// hyphens, underscores — no dot). Vendor domain-name namespaces MUST
45    /// NOT appear in this list; their support is signalled by
46    /// [`supports_vendor_namespaces`](Self::supports_vendor_namespaces).
47    #[serde(default)]
48    pub namespaces: Vec<String>,
49
50    /// Whether the server accepts vendor (domain-name) namespaces on this
51    /// data type (§1.2.1). Default `false`.
52    #[serde(default)]
53    pub supports_vendor_namespaces: bool,
54
55    /// Whether this account supports per-user `privateMetadata` on this
56    /// data type (§1.2.1). Default `false`.
57    ///
58    /// When `false`, the `privateMetadata` property MUST be absent from
59    /// response objects of this type, all `privateMetadata*` filter
60    /// conditions MUST be rejected with `unsupportedFilter`, and any `/set`
61    /// targeting `privateMetadata` MUST be rejected with
62    /// `invalidProperties`.
63    #[serde(default)]
64    pub supports_private: bool,
65
66    /// Maximum depth of nested objects within a namespace value (§1.2.1,
67    /// §2.1). `null` means no server-enforced limit.
68    ///
69    /// Depth 1 = flat properties only; depth 2 = one level of nesting.
70    /// Arrays do not contribute to depth themselves, but objects inside
71    /// arrays do (§2.1).
72    pub max_depth: Option<u64>,
73}