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