#[non_exhaustive]pub struct SessionClient { /* private fields */ }Expand description
A JmapClient bound to a JMAP session.
Obtain via JmapTasksExt::with_tasks_session.
All JMAP Tasks methods are available on this type without needing to pass
&Session on every call.
§Session lifecycle
SessionClient captures the Session at construction time. After
re-fetching the session via JmapClient::fetch_session, construct a new
SessionClient with the updated session. Reusing a stale SessionClient
after session expiry will result in unknownAccount or similar errors
from the server.
Clone is derived because JmapClient is itself cheap-to-clone (it
already implements Clone and with_tasks_session clones one
internally), enabling parallel-task fan-out with one bound session.
Debug is implemented manually to redact the inner JmapClient (which
holds an HTTP client and is intentionally not Debug in
jmap-base-client); only the Session is shown. This lets callers
embed a SessionClient in a #[derive(Debug)] struct without manual
impls of their own.
§Thread safety
SessionClient is Send + Sync. Both
jmap_base_client::JmapClient (backed by reqwest::Client) and
jmap_base_client::Session (plain serde-derived data) are
Send + Sync per jmap-base-client’s contract, so this type can be
shared across async tasks via Arc<SessionClient> or cloned for
per-task ownership.
A Send + Sync regression in a future jmap-base-client release
would be a major-version-breaking change for this crate. A
compile-time assertion in methods/mod.rs guards against the
regression landing silently — see
_assert_session_client_send_sync.
Implementations§
Source§impl SessionClient
impl SessionClient
Sourcepub async fn task_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<Task>, ClientError>
pub async fn task_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<Task>, ClientError>
Fetch Task objects by IDs (draft-tasks-06 §4.5).
If ids is None, the server returns all Tasks for the account,
SUBJECT TO the server’s maxObjectsInGet cap (RFC 8620 §5.1).
For production use, scope the result set via the corresponding
/query method first and pass explicit ids here to avoid
requestTooLarge errors when the account holds more objects
than the cap.
Pass properties: None to return all fields.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call:Http,Parse,AuthFailed,MethodError(wraps RFC 8620 §3.6.2 method-level errors such asaccountNotFound,invalidArguments,serverFail),MethodNotFound,ResponseTooLarge, orUnexpectedResponse.
Sourcepub async fn task_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn task_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Task objects since since_state (draft-tasks-06 §4.6).
§Errors
ClientError::InvalidArgumentifsince_stateis the empty string (defence-in-depth —Stateconstructed viaState::fromaccepts empty strings, but an emptysinceStateis never useful and would otherwise generate a wasted round-trip).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_get.
Sourcepub async fn task_set(
&self,
create: Option<Value>,
update: Option<HashMap<Id, PatchObject>>,
destroy: Option<Vec<Id>>,
) -> Result<SetResponse<Task>, ClientError>
pub async fn task_set( &self, create: Option<Value>, update: Option<HashMap<Id, PatchObject>>, destroy: Option<Vec<Id>>, ) -> Result<SetResponse<Task>, ClientError>
Create, update, or destroy Task objects (draft-tasks-06 §4.7).
update is Option<HashMap<Id, PatchObject>> (RFC 8620 §5.3). Wire
format is unchanged from a plain JSON object because PatchObject
is #[serde(transparent)]; the typed parameter binds the JSON Pointer
key + null-leaf removal contract to the type system.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.ClientError::InvalidArgumentifupdateisSomeandserde_json::to_valuefails on the patch map (pathological conditions only — allocation failure, or aPatchObjectwhose JSON tree exceedsserde_json’s recursion limit). The transient memory peak for very largeupdatemaps is roughly 3-4× theHashMap’s in-memory size (source map +serde_json::Valuetree + serializedVec<u8>body); callers dealing with thousands of patches per call may prefer to batch.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_get.
Sourcepub async fn task_copy(
&self,
from_account_id: &Id,
create: Value,
) -> Result<SetResponse<Task>, ClientError>
pub async fn task_copy( &self, from_account_id: &Id, create: Value, ) -> Result<SetResponse<Task>, ClientError>
Copy Tasks from another account (draft-tasks-06 §4.8).
from_account_id is the source account. The tasks are copied into the
current primary Tasks account.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_get. RFC 8620 §5.4 /copy adds method-level errorsfromAccountNotFound,fromAccountNotSupportedByMethod, andanchorNotFound; they surface asMethodError.
Sourcepub async fn task_query(
&self,
filter: Option<Value>,
sort: Option<Value>,
position: Option<u64>,
limit: Option<u64>,
) -> Result<QueryResponse, ClientError>
pub async fn task_query( &self, filter: Option<Value>, sort: Option<Value>, position: Option<u64>, limit: Option<u64>, ) -> Result<QueryResponse, ClientError>
Query Task IDs with optional filter and sort (draft-tasks-06 §4.13).
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_get. RFC 8620 §5.5 defines additional /query method-level errors (anchorNotFound,unsupportedFilter,unsupportedSort,tooManyChanges) that surface asMethodError.
Sourcepub async fn task_query_changes(
&self,
since_query_state: &State,
max_changes: Option<u64>,
filter: Option<Value>,
sort: Option<Value>,
up_to_id: Option<&Id>,
calculate_total: Option<bool>,
) -> Result<QueryChangesResponse, ClientError>
pub async fn task_query_changes( &self, since_query_state: &State, max_changes: Option<u64>, filter: Option<Value>, sort: Option<Value>, up_to_id: Option<&Id>, calculate_total: Option<bool>, ) -> Result<QueryChangesResponse, ClientError>
Fetch query-result changes for Task since since_query_state
(draft-tasks-06 §4.14).
filter and sort MUST match the filter / sort passed to the
original Task/query call that returned since_query_state —
RFC 8620 §5.6 is explicit that the server uses them to compute
which entries entered or left the result set.
up_to_id is the highest-index id the client has cached;
calculate_total requests the new total result count.
§Errors
ClientError::InvalidArgumentifsince_query_stateis the empty string (defence-in-depth empty-state guard; seeSelf::task_changes).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_get. RFC 8620 §5.6 also definescannotCalculateChanges(returned when the server cannot honour the request given the supplied filter / sort); it surfaces asMethodError.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn task_list_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<TaskList>, ClientError>
pub async fn task_list_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<TaskList>, ClientError>
Fetch TaskList objects by IDs (draft-tasks-06 §3.5).
If ids is None, the server returns all TaskLists for the account,
SUBJECT TO the server’s maxObjectsInGet cap (RFC 8620 §5.1).
For production use, scope the result set via the corresponding
/query method first and pass explicit ids here to avoid
requestTooLarge errors when the account holds more objects
than the cap.
Pass properties: None to return all fields.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call:Http,Parse,AuthFailed,MethodError(wraps RFC 8620 §3.6.2 method-level errors such asaccountNotFound,invalidArguments,serverFail),MethodNotFound,ResponseTooLarge, orUnexpectedResponse.
Sourcepub async fn task_list_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn task_list_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to TaskList objects since since_state (draft-tasks-06 §3.6).
If has_more_changes is true in the response, call again with new_state
as since_state until the flag is false.
§Errors
ClientError::InvalidArgumentifsince_stateis the empty string (defence-in-depth —Stateconstructed viaState::fromaccepts empty strings, but an emptysinceStateis never useful and would otherwise generate a wasted round-trip).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_list_get.
Sourcepub async fn task_list_set(
&self,
create: Option<Value>,
update: Option<HashMap<Id, PatchObject>>,
destroy: Option<Vec<Id>>,
params: Option<TaskListSetParams>,
) -> Result<SetResponse<TaskList>, ClientError>
pub async fn task_list_set( &self, create: Option<Value>, update: Option<HashMap<Id, PatchObject>>, destroy: Option<Vec<Id>>, params: Option<TaskListSetParams>, ) -> Result<SetResponse<TaskList>, ClientError>
Create, update, or destroy TaskList objects (draft-tasks-06 §3.7).
Pass create, update, and/or destroy as needed. All three are
optional; pass None to omit any operation from the request.
update is Option<HashMap<Id, PatchObject>> (RFC 8620 §5.3). Wire
format is unchanged from a plain JSON object because PatchObject
is #[serde(transparent)]; the typed parameter binds the JSON Pointer
key + null-leaf removal contract to the type system.
params carries extra method-level arguments
(TaskListSetParams). Pass None
(or Some(Default::default())) for spec-default behavior. Use
TaskListSetParams::on_destroy_remove_tasks
to allow destroying a non-empty TaskList (otherwise the server
returns taskListHasTasks), and
TaskListSetParams::extra for
vendor / site extension fields (workspace extras-preservation
policy).
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.ClientError::InvalidArgumentifupdateisSomeandserde_json::to_valuefails on the patch map (pathological conditions only; seeSelf::task_setfor the memory-cost discussion that applies identically here).- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_list_get.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn task_notification_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<TaskNotification>, ClientError>
pub async fn task_notification_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<TaskNotification>, ClientError>
Fetch TaskNotification objects by IDs (draft-tasks-06 §5.2).
If ids is None, the server returns all TaskNotifications for the account,
SUBJECT TO the server’s maxObjectsInGet cap (RFC 8620 §5.1).
For production use, scope the result set via the corresponding
/query method first and pass explicit ids here to avoid
requestTooLarge errors when the account holds more objects
than the cap.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call:Http,Parse,AuthFailed,MethodError(wraps RFC 8620 §3.6.2 method-level errors such asaccountNotFound,invalidArguments,serverFail),MethodNotFound,ResponseTooLarge, orUnexpectedResponse.
Sourcepub async fn task_notification_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn task_notification_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to TaskNotification objects since since_state
(draft-tasks-06 §5.3).
§Errors
ClientError::InvalidArgumentifsince_stateis the empty string (defence-in-depth —Stateconstructed viaState::fromaccepts empty strings, but an emptysinceStateis never useful and would otherwise generate a wasted round-trip).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_notification_get.
Sourcepub async fn task_notification_set(
&self,
destroy: Vec<Id>,
) -> Result<SetResponse, ClientError>
pub async fn task_notification_set( &self, destroy: Vec<Id>, ) -> Result<SetResponse, ClientError>
Destroy TaskNotification objects (draft-tasks-06 §5.4).
Destroy-only: TaskNotification/set only supports destroy.
The server creates notifications automatically; clients may only remove them.
Passing an empty destroy list is valid and produces an empty /set response.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_notification_get.
Sourcepub async fn task_notification_query(
&self,
filter: Option<Value>,
sort: Option<Value>,
position: Option<u64>,
limit: Option<u64>,
) -> Result<QueryResponse, ClientError>
pub async fn task_notification_query( &self, filter: Option<Value>, sort: Option<Value>, position: Option<u64>, limit: Option<u64>, ) -> Result<QueryResponse, ClientError>
Query TaskNotification IDs with optional filter and sort (draft-tasks-06 §5.5).
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_notification_get. RFC 8620 §5.5 defines additional /query method-level errors (anchorNotFound,unsupportedFilter,unsupportedSort,tooManyChanges) that surface asMethodError.
Sourcepub async fn task_notification_query_changes(
&self,
since_query_state: &State,
max_changes: Option<u64>,
filter: Option<Value>,
sort: Option<Value>,
up_to_id: Option<&Id>,
calculate_total: Option<bool>,
) -> Result<QueryChangesResponse, ClientError>
pub async fn task_notification_query_changes( &self, since_query_state: &State, max_changes: Option<u64>, filter: Option<Value>, sort: Option<Value>, up_to_id: Option<&Id>, calculate_total: Option<bool>, ) -> Result<QueryChangesResponse, ClientError>
Fetch query-result changes for TaskNotification since since_query_state
(draft-tasks-06 §5.6).
filter and sort MUST match the filter / sort passed to the
original TaskNotification/query call that returned
since_query_state — RFC 8620 §5.6 is explicit that the server uses
them to compute which entries entered or left the result set.
up_to_id is the highest-index id the client has cached;
calculate_total requests the new total result count.
§Errors
ClientError::InvalidArgumentifsince_query_stateis the empty string (defence-in-depth empty-state guard; seeSelf::task_notification_changes).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:tasks.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::task_notification_get. RFC 8620 §5.6 also definescannotCalculateChanges(returned when the server cannot honour the request given the supplied filter / sort); it surfaces asMethodError.
Source§impl SessionClient
impl SessionClient
Sourcepub fn client(&self) -> &JmapClient
pub fn client(&self) -> &JmapClient
Borrow the underlying JmapClient.
Useful for ad-hoc operations outside the typed JMAP method surface —
for example, calling JmapClient::upload / JmapClient::download_blob,
or constructing a JmapClient::event_source subscription using the
bound session’s event_source_url.
Sourcepub fn session(&self) -> &Session
pub fn session(&self) -> &Session
Borrow the captured Session.
SessionClient captures the Session at construction time. After
re-fetching the session via JmapClient::fetch_session, callers
should construct a new SessionClient. This accessor lets a caller
compare the captured session’s state field against a freshly
fetched session to detect staleness, or inspect
accountCapabilities / primary_accounts for capability-specific
metadata not exposed via the typed JMAP method surface.
Sourcepub fn tasks_account_id(&self) -> Result<&str, ClientError>
pub fn tasks_account_id(&self) -> Result<&str, ClientError>
Return the primary account id for urn:ietf:params:jmap:tasks,
or Err(InvalidSession) if the session has no primary account for
that capability.
Trait Implementations§
Source§impl Clone for SessionClient
impl Clone for SessionClient
Source§fn clone(&self) -> SessionClient
fn clone(&self) -> SessionClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more