jmap_tasks_client/lib.rs
1//! JMAP Tasks extension client methods.
2//!
3//! # Usage
4//!
5//! ```rust,no_run
6//! # use jmap_tasks_client::JmapTasksExt;
7//! # async fn example(client: jmap_base_client::JmapClient) -> Result<(), jmap_base_client::ClientError> {
8//! let session = client.fetch_session().await?;
9//! let sc = client.with_tasks_session(session);
10//! let task_lists = sc.task_list_get(None, None).await?;
11//! # Ok(())
12//! # }
13//! ```
14
15#![forbid(unsafe_code)]
16
17pub mod methods;
18
19pub use jmap_base_client::ClientError;
20pub use methods::{
21 AddedItem, ChangesResponse, GetResponse, QueryChangesResponse, QueryResponse, SessionClient,
22 SetError, SetResponse,
23};
24
25// ---------------------------------------------------------------------------
26// JmapTasksExt — the extension trait
27// ---------------------------------------------------------------------------
28
29/// Extension trait adding JMAP Tasks methods to [`jmap_base_client::JmapClient`].
30///
31/// Import this trait to use: `use jmap_tasks_client::JmapTasksExt;`
32pub trait JmapTasksExt {
33 /// Bind this client to a JMAP session for use with Tasks methods.
34 ///
35 /// The returned [`SessionClient`] captures the session at construction time.
36 /// After re-fetching the session, construct a new `SessionClient` with the
37 /// updated session.
38 fn with_tasks_session(self, session: jmap_base_client::Session) -> methods::SessionClient;
39}
40
41impl JmapTasksExt for jmap_base_client::JmapClient {
42 fn with_tasks_session(self, session: jmap_base_client::Session) -> methods::SessionClient {
43 methods::SessionClient {
44 client: self,
45 session,
46 }
47 }
48}