#[non_exhaustive]pub struct SessionClient { /* private fields */ }Expand description
A JmapClient bound to a JMAP session.
Obtain via JmapMetadataExt::with_metadata_session.
All JMAP Metadata 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_metadata_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 metadata_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<Metadata>, ClientError>
pub async fn metadata_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<Metadata>, ClientError>
Fetch Metadata objects by IDs (draft-ietf-jmap-metadata-01 §3.2).
If ids is None, the server returns all Metadata objects for the
account in one response. Pass properties: None to return all
fields.
Sourcepub async fn metadata_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
params: Option<MetadataChangesParams>,
) -> Result<ChangesResponse, ClientError>
pub async fn metadata_changes( &self, since_state: &State, max_changes: Option<u64>, params: Option<MetadataChangesParams>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Metadata objects since since_state
(draft-ietf-jmap-metadata-01 §3.3).
If has_more_changes is true in the response, call again with
new_state as since_state until the flag is false.
params carries the Metadata-specific optional filters
filterRelatedType and filterMetadataType. Pass None (or
Some(Default::default())) to fetch unfiltered changes. Per §3.3,
clients that use these filters MUST re-use the same filter values
across subsequent calls to ensure consistent synchronisation,
because the returned state token represents the complete account
state and is independent of the filter selection.
Sourcepub async fn metadata_set(
&self,
create: Option<Value>,
update: Option<HashMap<Id, PatchObject>>,
destroy: Option<Vec<Id>>,
) -> Result<SetResponse<Metadata>, ClientError>
pub async fn metadata_set( &self, create: Option<Value>, update: Option<HashMap<Id, PatchObject>>, destroy: Option<Vec<Id>>, ) -> Result<SetResponse<Metadata>, ClientError>
Create, update, or destroy Metadata objects (draft-ietf-jmap-metadata-01 §3.1).
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.
The server enforces uniqueness on the tuple
(relatedType, relatedId, @type, isPrivate) and may return
alreadyExists, forbidden (if maySetPrivate: false and
isPrivate: true is requested), overQuota, or
invalidProperties SetErrors per §3.1.
Sourcepub async fn metadata_query(
&self,
filter: Option<Value>,
sort: Option<Value>,
position: Option<u64>,
limit: Option<u64>,
) -> Result<QueryResponse, ClientError>
pub async fn metadata_query( &self, filter: Option<Value>, sort: Option<Value>, position: Option<u64>, limit: Option<u64>, ) -> Result<QueryResponse, ClientError>
Query Metadata IDs with optional filter and sort (draft-ietf-jmap-metadata-01 §3.4).
Pass filter: None and sort: None to return all Metadata IDs with
server-default ordering. Use position and limit for pagination.
The filter value is typed by the caller; the canonical type is
jmap_metadata_types::MetadataFilterCondition (§3.4.1) wrapped in
jmap_types::query::Filter. This builder accepts a serde_json::Value
so callers can mix filter conditions with FilterOperator algebra
without forcing a single type through the API.
Sort comparators MUST set property to one of id, @type,
relatedType, relatedId, or isPrivate per §3.4.2; id MUST be
supported by every server, the others SHOULD be supported.
Sourcepub async fn metadata_query_changes(
&self,
since_query_state: &State,
max_changes: Option<u64>,
) -> Result<QueryChangesResponse, ClientError>
pub async fn metadata_query_changes( &self, since_query_state: &State, max_changes: Option<u64>, ) -> Result<QueryChangesResponse, ClientError>
Fetch query-result changes for Metadata since since_query_state
(draft-ietf-jmap-metadata-01 §3.5).
Returns which Metadata IDs were removed from or added to the query
result set since the given state. max_changes may be None.
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