jmap_metadata_client/lib.rs
1//! jmap-metadata-client — JMAP Object Metadata extension method implementations.
2//!
3//! Implements the client-side method bindings for
4//! [draft-ietf-jmap-metadata-01](https://www.ietf.org/archive/id/draft-ietf-jmap-metadata-01.txt).
5//! Depends on `jmap-base-client` for transport, auth, and session, and on
6//! `jmap-metadata-types` for the wire types.
7//!
8//! Cookie-cut from `jmap-mail-client` (canonical extension-client template
9//! per workspace AGENTS.md).
10//!
11//! # Usage
12//!
13//! ```rust,no_run
14//! # use jmap_metadata_client::JmapMetadataExt;
15//! # async fn example(client: jmap_base_client::JmapClient) -> Result<(), jmap_base_client::ClientError> {
16//! let session = client.fetch_session().await?;
17//! let sc = client.with_metadata_session(session);
18//! // Fetch all Metadata objects in the account.
19//! let metadata = sc.metadata_get(None, None).await?;
20//! # let _ = metadata;
21//! # Ok(())
22//! # }
23//! ```
24
25#![forbid(unsafe_code)]
26
27pub mod methods;
28
29pub use jmap_base_client::ClientError;
30pub use methods::{
31 AddedItem, ChangesResponse, GetResponse, MetadataChangesParams, QueryChangesResponse,
32 QueryResponse, SessionClient, SetError, SetResponse,
33};
34
35/// Extension trait adding JMAP Object Metadata (draft-ietf-jmap-metadata-01)
36/// methods to [`jmap_base_client::JmapClient`].
37///
38/// Import this trait to use: `use jmap_metadata_client::JmapMetadataExt;`
39///
40/// All JMAP Metadata method calls are made through the [`SessionClient`]
41/// returned by [`with_metadata_session`](JmapMetadataExt::with_metadata_session).
42pub trait JmapMetadataExt {
43 /// Create a [`SessionClient`] bound to this client and session.
44 ///
45 /// All JMAP Metadata method calls are made through the returned
46 /// [`SessionClient`].
47 fn with_metadata_session(&self, session: jmap_base_client::Session) -> methods::SessionClient;
48}
49
50impl JmapMetadataExt for jmap_base_client::JmapClient {
51 fn with_metadata_session(&self, session: jmap_base_client::Session) -> methods::SessionClient {
52 methods::SessionClient {
53 client: self.clone(),
54 session,
55 }
56 }
57}