#[non_exhaustive]pub struct SessionClient { /* private fields */ }Expand description
A JmapClient bound to a JMAP session.
Obtain via JmapMailExt::with_mail_session.
All JMAP Mail 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_mail_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.
Implementations§
Source§impl SessionClient
impl SessionClient
Sourcepub async fn email_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
params: Option<EmailGetParams>,
) -> Result<GetResponse<Email>, ClientError>
pub async fn email_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, params: Option<EmailGetParams>, ) -> Result<GetResponse<Email>, ClientError>
Fetch Email objects by IDs (RFC 8621 §4.1.8 — Email/get).
If ids is None, the server returns all Emails for the account.
Pass properties: None to return all fields.
Pass params: None to use server defaults for body-fetch options.
Sourcepub async fn email_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn email_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Email objects since since_state (RFC 8621 §4.2 — Email/changes).
If has_more_changes is true in the response, call again with new_state
as since_state until the flag is false.
Sourcepub async fn email_set(
&self,
create: Option<Value>,
update: Option<HashMap<Id, PatchObject>>,
destroy: Option<Vec<Id>>,
if_in_state: Option<&State>,
) -> Result<SetResponse<Email>, ClientError>
pub async fn email_set( &self, create: Option<Value>, update: Option<HashMap<Id, PatchObject>>, destroy: Option<Vec<Id>>, if_in_state: Option<&State>, ) -> Result<SetResponse<Email>, ClientError>
Create, update, or destroy Email objects (RFC 8621 §4.3 — Email/set).
Pass create, update, and/or destroy as needed. All three are
optional; pass None to omit any operation from the request.
Pass if_in_state: Some(&state) to use an optimistic-concurrency guard.
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.
Sourcepub async fn email_query(
&self,
filter: Option<Value>,
sort: Option<Value>,
position: Option<u64>,
limit: Option<u64>,
collapse_threads: Option<bool>,
) -> Result<QueryResponse, ClientError>
pub async fn email_query( &self, filter: Option<Value>, sort: Option<Value>, position: Option<u64>, limit: Option<u64>, collapse_threads: Option<bool>, ) -> Result<QueryResponse, ClientError>
Query Email IDs with optional filter and sort (RFC 8621 §4.4 — Email/query).
Pass filter: None and sort: None to return all Emails with
server-default ordering. Use position and limit for pagination.
Pass collapse_threads: Some(true) to return at most one email per thread.
Sourcepub async fn email_query_changes(
&self,
since_query_state: &State,
max_changes: Option<u64>,
collapse_threads: Option<bool>,
) -> Result<QueryChangesResponse, ClientError>
pub async fn email_query_changes( &self, since_query_state: &State, max_changes: Option<u64>, collapse_threads: Option<bool>, ) -> Result<QueryChangesResponse, ClientError>
Fetch query-result changes for Email since since_query_state
(RFC 8621 §4.5 — Email/queryChanges).
Sourcepub async fn email_copy(
&self,
params: EmailCopyParams,
create: Value,
) -> Result<SetResponse<Email>, ClientError>
pub async fn email_copy( &self, params: EmailCopyParams, create: Value, ) -> Result<SetResponse<Email>, ClientError>
Copy Emails from another account (RFC 8621 §4.7 — Email/copy).
params carries fromAccountId and optional destroy-after-copy flags.
create is a map of creation keys to partial Email objects (with new
mailboxIds etc.) as described in RFC 8621 §4.7.
Sourcepub async fn email_import(
&self,
emails: &HashMap<String, EmailImportInput<'_>>,
if_in_state: Option<&State>,
) -> Result<EmailImportResponse, ClientError>
pub async fn email_import( &self, emails: &HashMap<String, EmailImportInput<'_>>, if_in_state: Option<&State>, ) -> Result<EmailImportResponse, ClientError>
Import raw RFC 5322 messages into the account (RFC 8621 §4.8 — Email/import).
Each entry in emails maps a caller-chosen creation id to an
EmailImportInput referencing a previously uploaded blob and the
target mailbox(es). The blob must have been uploaded via the standard
blob-upload mechanism on jmap-base-client before calling this method.
At least one mailbox id is required per RFC 8621 §4.8; the empty-set
case is rejected client-side as InvalidArgument. An empty emails
map is also rejected — a no-op import is never useful and would
generate a round-trip with no successful creations.
Pass if_in_state: Some(&state) for an optimistic-concurrency guard
against the Email object state (RFC 8621 §4.8 returns stateMismatch
if the supplied state does not match).
Per-creation failures appear in EmailImportResponse::not_created
as super::SetError values; possible error codes include alreadyExists
(with an existingId extra field), invalidProperties, overQuota,
and invalidEmail.
Sourcepub async fn email_parse(
&self,
blob_ids: &[Id],
params: Option<EmailParseParams>,
) -> Result<EmailParseResponse, ClientError>
pub async fn email_parse( &self, blob_ids: &[Id], params: Option<EmailParseParams>, ) -> Result<EmailParseResponse, ClientError>
Parse uploaded blobs as RFC 5322 messages without importing them (RFC 8621 §4.9 — Email/parse).
Returns Email objects derived from each blob. Per RFC 8621 §4.9 the
returned Emails have id, mailboxIds, keywords, and receivedAt
set to null (the messages are not in the mail store); threadId
MAY be present if the server can predict the assignment.
Pass params: None to use server defaults for properties and body
fetching. The set of properties returned defaults to the spec-listed
header/body fields documented in RFC 8621 §4.9.
Empty blob_ids is rejected as InvalidArgument — a no-op parse
round-trip is never useful.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn identity_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<Identity>, ClientError>
pub async fn identity_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<Identity>, ClientError>
Fetch Identity objects by IDs (RFC 8621 §6.1 — Identity/get).
If ids is None, the server returns all Identities for the account.
Pass properties: None to return all fields.
Sourcepub async fn identity_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn identity_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Identity objects since since_state (RFC 8621 §6.2 — Identity/changes).
Sourcepub async fn identity_set(
&self,
create: Option<Value>,
update: Option<HashMap<Id, PatchObject>>,
destroy: Option<Vec<Id>>,
) -> Result<SetResponse<Identity>, ClientError>
pub async fn identity_set( &self, create: Option<Value>, update: Option<HashMap<Id, PatchObject>>, destroy: Option<Vec<Id>>, ) -> Result<SetResponse<Identity>, ClientError>
Create, update, or destroy Identity objects (RFC 8621 §6.3 — Identity/set).
Pass create, update, and/or destroy as needed. Pass None to omit.
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.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn mailbox_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<Mailbox>, ClientError>
pub async fn mailbox_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<Mailbox>, ClientError>
Fetch Mailbox objects by IDs (RFC 8621 §2.1 — Mailbox/get).
If ids is None, the server returns all Mailboxes for the account.
Pass properties: None to return all fields.
Sourcepub async fn mailbox_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn mailbox_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Mailbox objects since since_state (RFC 8621 §2.2 — Mailbox/changes).
Sourcepub async fn mailbox_set(
&self,
create: Option<Value>,
update: Option<HashMap<Id, PatchObject>>,
destroy: Option<Vec<Id>>,
params: Option<MailboxSetParams>,
) -> Result<SetResponse<Mailbox>, ClientError>
pub async fn mailbox_set( &self, create: Option<Value>, update: Option<HashMap<Id, PatchObject>>, destroy: Option<Vec<Id>>, params: Option<MailboxSetParams>, ) -> Result<SetResponse<Mailbox>, ClientError>
Create, update, or destroy Mailbox objects (RFC 8621 §2.5 — Mailbox/set).
Pass create, update, and/or destroy as needed. Pass None to omit.
Pass params: Some(MailboxSetParams { on_destroy_remove_emails: Some(true) })
to allow destroying a non-empty mailbox.
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.
Sourcepub async fn mailbox_query(
&self,
filter: Option<Value>,
sort: Option<Value>,
position: Option<u64>,
limit: Option<u64>,
) -> Result<QueryResponse, ClientError>
pub async fn mailbox_query( &self, filter: Option<Value>, sort: Option<Value>, position: Option<u64>, limit: Option<u64>, ) -> Result<QueryResponse, ClientError>
Query Mailbox IDs with optional filter and sort (RFC 8621 §2.3 — Mailbox/query).
Pass filter: None and sort: None to return all Mailboxes with
server-default ordering. Use position and limit for pagination.
Sourcepub async fn mailbox_query_changes(
&self,
since_query_state: &State,
max_changes: Option<u64>,
) -> Result<QueryChangesResponse, ClientError>
pub async fn mailbox_query_changes( &self, since_query_state: &State, max_changes: Option<u64>, ) -> Result<QueryChangesResponse, ClientError>
Fetch query-result changes for Mailbox since since_query_state
(RFC 8621 §2.4 — Mailbox/queryChanges).
Source§impl SessionClient
impl SessionClient
Sourcepub async fn search_snippet_get(
&self,
account_id: Option<&Id>,
filter: Value,
thread_ids: Option<&[Id]>,
email_ids: Option<&[Id]>,
) -> Result<Value, ClientError>
pub async fn search_snippet_get( &self, account_id: Option<&Id>, filter: Value, thread_ids: Option<&[Id]>, email_ids: Option<&[Id]>, ) -> Result<Value, ClientError>
Fetch SearchSnippet objects (RFC 8621 §5 — SearchSnippet/get).
filter is the same filter object used in Email/query. Either
thread_ids or email_ids (or both) may be provided to scope the
snippets; the server returns one SearchSnippet per email in the
result set.
Returns the raw response value because the SearchSnippet/get response
shape differs from the standard /get shape (no state, no notFound).
Callers should deserialize into Vec<jmap_mail_types::SearchSnippet> via
response["list"].as_array().
Source§impl SessionClient
impl SessionClient
Sourcepub async fn email_submission_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<EmailSubmission>, ClientError>
pub async fn email_submission_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<EmailSubmission>, ClientError>
Fetch EmailSubmission objects by IDs (RFC 8621 §7.1 — EmailSubmission/get).
If ids is None, the server returns all submissions for the account.
Pass properties: None to return all fields.
Sourcepub async fn email_submission_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn email_submission_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to EmailSubmission objects since since_state
(RFC 8621 §7.2 — EmailSubmission/changes).
Sourcepub async fn email_submission_query(
&self,
filter: Option<Value>,
sort: Option<Value>,
position: Option<u64>,
limit: Option<u64>,
) -> Result<QueryResponse, ClientError>
pub async fn email_submission_query( &self, filter: Option<Value>, sort: Option<Value>, position: Option<u64>, limit: Option<u64>, ) -> Result<QueryResponse, ClientError>
Query EmailSubmission IDs with optional filter and sort (RFC 8621 §7.3 — EmailSubmission/query).
The sort property for this object type is "sentAt" (RFC 8621 §7.3, line 4513),
not "sendAt" (which is an object field). Callers constructing the sort
argument should use "sentAt" as the property name.
Sourcepub async fn email_submission_query_changes(
&self,
since_query_state: &State,
max_changes: Option<u64>,
filter: Option<Value>,
sort: Option<Value>,
) -> Result<QueryChangesResponse, ClientError>
pub async fn email_submission_query_changes( &self, since_query_state: &State, max_changes: Option<u64>, filter: Option<Value>, sort: Option<Value>, ) -> Result<QueryChangesResponse, ClientError>
Fetch query-result changes for EmailSubmission since since_query_state
(RFC 8621 §7.4 — EmailSubmission/queryChanges).
Sourcepub async fn email_submission_set(
&self,
create: Option<Value>,
update: Option<HashMap<Id, PatchObject>>,
destroy: Option<Vec<Id>>,
if_in_state: Option<&State>,
params: Option<EmailSubmissionSetParams>,
) -> Result<SetResponse<EmailSubmission>, ClientError>
pub async fn email_submission_set( &self, create: Option<Value>, update: Option<HashMap<Id, PatchObject>>, destroy: Option<Vec<Id>>, if_in_state: Option<&State>, params: Option<EmailSubmissionSetParams>, ) -> Result<SetResponse<EmailSubmission>, ClientError>
Create, update, or destroy EmailSubmission objects (RFC 8621 §7.5 — EmailSubmission/set).
The optional params argument carries the two success-hook fields:
on_success_update_email— aPatchObjectmap (keyed by submission creation key) of patches to apply to the associated Email when the submission is created successfully (RFC 8621 §7.5).on_success_destroy_email— IDs (or#-reference creation keys) of Email objects to destroy when the submission is created successfully (RFC 8621 §7.5).
Source§impl SessionClient
impl SessionClient
Sourcepub async fn thread_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<Thread>, ClientError>
pub async fn thread_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<Thread>, ClientError>
Fetch Thread objects by IDs (RFC 8621 §3.1 — Thread/get).
If ids is None, the server returns all Threads for the account.
Pass properties: None to return all fields.
Sourcepub async fn thread_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn thread_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Thread objects since since_state (RFC 8621 §3.2 — Thread/changes).
If has_more_changes is true in the response, call again with new_state
as since_state until the flag is false.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn vacation_response_get(
&self,
) -> Result<GetResponse<VacationResponse>, ClientError>
pub async fn vacation_response_get( &self, ) -> Result<GetResponse<VacationResponse>, ClientError>
Fetch the VacationResponse singleton for the account (RFC 8621 §8).
The server always returns a single VacationResponse object whose id
is "singleton". There is no need to pass ids.
Sourcepub async fn vacation_response_set(
&self,
update: Option<HashMap<Id, PatchObject>>,
) -> Result<SetResponse<VacationResponse>, ClientError>
pub async fn vacation_response_set( &self, update: Option<HashMap<Id, PatchObject>>, ) -> Result<SetResponse<VacationResponse>, ClientError>
Update the VacationResponse singleton (RFC 8621 §8).
update should be a JSON object of the form:
{ "singleton": { "isEnabled": true, "subject": "Out of office" } }create and destroy are not supported by VacationResponse/set.
update is Option<HashMap<Id, PatchObject>> (RFC 8620 §5.3). The
usual shape is {"singleton": <patch>}. Wire format is unchanged
from a plain JSON object because PatchObject is
#[serde(transparent)].
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