Skip to main content

jmap_metadata_types/
lib.rs

1//! JMAP Object Metadata extension data types.
2//!
3//! Implements the data types defined in
4//! [draft-ietf-jmap-metadata-02](https://datatracker.ietf.org/doc/draft-ietf-jmap-metadata/).
5//! Types only — no method handlers, no async, no network I/O.
6//!
7//! ## Architecture change from -01 to -02
8//!
9//! draft-ietf-jmap-metadata-02 eliminates the standalone `Metadata` object
10//! type entirely. Instead, each opted-in data type gains `metadata` (shared)
11//! and `privateMetadata` (per-user) properties — plain `String[Object]` maps
12//! keyed by namespace identifier.
13//!
14//! This crate provides the helper types that consumers need:
15//!
16//! - [`capability`] — [`DataTypeMetadataInfo`], [`JMAP_METADATA_URI`] (§1.2.1)
17//! - [`filter`] — [`MetadataTextMatch`], [`WithMetadata`] (§3.5)
18//! - [`namespace`] — namespace identifier validation (§2.1)
19//!
20//! All public types and functions are re-exported at the crate root.
21//!
22//! # Example
23//!
24//! ```rust
25//! use jmap_metadata_types::{DataTypeMetadataInfo, is_valid_namespace};
26//!
27//! // Server advertises per-type metadata capability
28//! let json = r#"{
29//!     "namespaces": ["photography"],
30//!     "supportsVendorNamespaces": false,
31//!     "supportsPrivate": false,
32//!     "maxDepth": 3
33//! }"#;
34//! let info: DataTypeMetadataInfo = serde_json::from_str(json).unwrap();
35//! assert_eq!(info.namespaces, vec!["photography"]);
36//! assert_eq!(info.max_depth, Some(3));
37//!
38//! // Validate namespace identifiers
39//! assert!(is_valid_namespace("photography"));       // registered
40//! assert!(is_valid_namespace("acme.example.com"));  // vendor domain
41//! assert!(!is_valid_namespace(""));                 // empty
42//! ```
43
44#![forbid(unsafe_code)]
45
46pub mod capability;
47pub mod filter;
48pub mod namespace;
49
50pub use capability::{DataTypeMetadataInfo, JMAP_METADATA_URI};
51pub use filter::{MetadataTextMatch, WithMetadata};
52pub use namespace::{is_registered_namespace, is_valid_namespace, is_vendor_namespace};