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-04](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//! Since -02, the draft has no standalone `Metadata` object type. Instead,
10//! each listed data type gains `metadata` (shared) and `privateMetadata`
11//! (per-user) properties — plain `String[Object]` maps keyed by namespace
12//! identifier.
13//!
14//! This crate provides the helper types that consumers need:
15//!
16//! - Crate root — [`DataTypeMetadataInfo`], [`JMAP_METADATA_URI`] (§1.2.1)
17//! - `filter` — [`MetadataTextMatch`], [`WithMetadata`] (§3.6)
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
46mod capability;
47mod filter;
48mod 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};