Skip to main content

jmap_types/
lib.rs

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