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-01](https://datatracker.ietf.org/doc/draft-ietf-jmap-metadata/).
5//! Types only — no method handlers, no async, no network I/O.
6//!
7//! ## Module layout
8//!
9//! - [`metadata`] — [`Metadata`], [`Annotation`], [`ImapMetadata`],
10//!   [`WebDavMetadata`] (§2)
11//! - [`capability`] — [`MetadataCapability`], [`JMAP_METADATA_URI`] (§1.2.1)
12//! - [`filter`] — [`MetadataFilterCondition`] (§3.4.1)
13//! - [`backend`] — [`MetadataProperty`] and `JmapObject` trait impls
14//!
15//! All public types are re-exported at the crate root.
16//!
17//! # Example
18//!
19//! ```rust
20//! use jmap_metadata_types::{Annotation, Metadata};
21//!
22//! let json = r#"{
23//!     "@type": "Annotation",
24//!     "id": "MD789",
25//!     "relatedType": "Email",
26//!     "relatedId": "EM456",
27//!     "isPrivate": true,
28//!     "acme.example.com:workflowState": "pending-review"
29//! }"#;
30//!
31//! let meta: Metadata = serde_json::from_str(json).unwrap();
32//! match meta {
33//!     Metadata::Annotation(Annotation { ref related_type, ref extra, .. }) => {
34//!         // `related_type` is `Option<String>` so the §4.1 extended-`/get`
35//!         // partial-response shape (which can omit it, per the §7.2
36//!         // example) round-trips losslessly. Full `Metadata/get` and
37//!         // `Metadata/set` responses always populate it.
38//!         assert_eq!(related_type.as_deref(), Some("Email"));
39//!         assert_eq!(
40//!             extra.get("acme.example.com:workflowState"),
41//!             Some(&serde_json::Value::String("pending-review".into())),
42//!         );
43//!     }
44//!     _ => panic!("expected Annotation variant"),
45//! }
46//! ```
47
48#![forbid(unsafe_code)]
49
50pub mod backend;
51pub mod capability;
52pub mod filter;
53pub mod metadata;
54
55pub use backend::MetadataProperty;
56pub use capability::{MetadataCapability, JMAP_METADATA_URI};
57pub use filter::{MetadataFilter, MetadataFilterCondition};
58pub use metadata::{Annotation, ImapMetadata, Metadata, WebDavMetadata};
59
60/// Generic filter algebra from `jmap-types::query` (RFC 8620 §5.5).
61///
62/// Re-exported here so callers of `jmap-metadata-types` do not need a
63/// direct dependency on `jmap-types`. Mirrors the canonical
64/// [`jmap_mail_types::query`] re-exports from the workspace canonical
65/// extension-types template.
66///
67/// [`jmap_mail_types::query`]: https://docs.rs/jmap-mail-types/latest/jmap_mail_types/query/index.html
68pub use jmap_types::query::{Filter, FilterOperator, Operator};