jmap_types/lib.rs
1//! Shared JMAP wire types for RFC 8620.
2//!
3//! Provides [`Id`], [`UTCDate`], [`State`], [`JmapError`],
4//! [`JmapRequest`], [`JmapResponse`], [`Filter`], [`ResultReference`], and
5//! the RFC 8620 §7 push types ([`StateChange`], [`PushSubscription`]) —
6//! the primitives shared by all crates in the `jmap-*` family.
7//!
8//! This crate is types-only: no method handlers, no async, no network I/O.
9//! It is the root dependency for `jmap-mail-types`, `jmap-chat-types`, and
10//! all server and client crates in the family.
11//!
12//! All types implement [`serde::Serialize`] and [`serde::Deserialize`] with the
13//! camelCase field names required by the JMAP wire format.
14//!
15//! # Example
16//!
17//! ```rust
18//! use jmap_types::JmapRequest;
19//!
20//! let json = r#"{
21//! "using": ["urn:ietf:params:jmap:core"],
22//! "methodCalls": [["Mailbox/get", {"accountId": "a1"}, "c0"]]
23//! }"#;
24//!
25//! let req: JmapRequest = serde_json::from_str(json).unwrap();
26//! assert_eq!(req.using[0], "urn:ietf:params:jmap:core");
27//! assert_eq!(req.method_calls[0].name, "Mailbox/get");
28//! ```
29
30#![forbid(unsafe_code)]
31
32pub mod backend;
33pub mod error;
34pub mod id;
35pub mod methods;
36pub mod patch;
37pub mod push;
38pub mod query;
39pub mod resultref;
40pub mod wire;
41
42// `string_enum` is a private module that hosts the [`impl_string_enum!`]
43// declarative macro. The macro itself is `#[macro_export]`-ed, so it is
44// reachable as `jmap_types::impl_string_enum!` regardless of this `mod`'s
45// visibility. See bd JMAP-wk77.
46mod string_enum;
47
48pub use backend::{GetObject, JmapObject, QueryObject, SetObject};
49pub use error::JmapError;
50pub use id::{Date, Id, State, UTCDate, ValidationError};
51pub use methods::{
52 AddedItem, ChangesResponse, GetResponse, QueryChangesResponse, QueryResponse, SetError,
53 SetResponse,
54};
55pub use patch::PatchObject;
56pub use push::{PushKeys, PushSubscription, PushVerification, StateChange};
57pub use query::{Filter, FilterOperator, Operator};
58pub use resultref::{Argument, ResultReference};
59pub use wire::{Invocation, JmapRequest, JmapResponse};