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#![cfg_attr(docsrs, feature(doc_cfg))]
32#![forbid(unsafe_code)]
33
34mod backend;
35pub mod conditional;
36pub mod data_types;
37mod error;
38pub mod i18n;
39mod id;
40mod jmap_uri;
41mod methods;
42mod patch;
43pub mod problem;
44mod push;
45mod query;
46mod resultref;
47mod set_error;
48mod wire;
49
50// `string_enum` is a private module that hosts the [`impl_string_enum!`]
51// declarative macro. The macro itself is `#[macro_export]`-ed, so it is
52// reachable as `jmap_types::impl_string_enum!` regardless of this `mod`'s
53// visibility. See bd JMAP-wk77.
54mod string_enum;
55pub mod text;
56pub mod uri;
57
58pub use backend::{GetObject, JmapObject, QueryObject, SetObject, check_property_classification};
59pub use error::{JmapError, MethodErrorType, json_type_name};
60pub use id::{Date, Id, State, UTCDate, ValidationError};
61pub use jmap_uri::{JmapUri, JmapUriError};
62pub use methods::{
63 AddedItem, ChangesResponse, CopyResponse, GetResponse, PartialObject, QueryChangesResponse,
64 QueryResponse, SetResponse,
65};
66pub use patch::PatchObject;
67pub use push::{PushKeys, PushSubscription, PushVerification, StateChange, Urgency};
68pub use query::{Filter, FilterOperator, Operator};
69pub use resultref::{Argument, ResultReference};
70pub use set_error::{ReservedExtrasKey, SetError, SetErrorType};
71pub use wire::{Invocation, JmapRequest, JmapResponse};