#[non_exhaustive]pub struct SessionClient { /* private fields */ }Expand description
A JmapClient bound to a JMAP session.
Obtain via the chat extension methods that accept a Session. All JMAP
Chat methods are available on this type without needing to pass &Session
on every call.
§Session lifecycle
SessionClient captures the Session at construction time. JMAP sessions
can expire; 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_chat_session clones one
internally), enabling parallel-task fan-out with one bound session.
§Concurrency
SessionClient is Send + Sync and may be used from any tokio
task. Cloning is cheap: the underlying JmapClient wraps a
reqwest::Client that is itself Clone over an internal Arc,
so every clone shares the same HTTP connection pool. There is no
benefit to constructing independent SessionClients for
per-worker fan-out — clone the existing one.
Concurrent calls on a single SessionClient (or on clones) are
safe but unordered: reqwest does not guarantee that
responses arrive in request order across concurrent
in-flight calls. When ordering matters between method calls (e.g.
a Foo/set followed by a Foo/changes that must observe the new
state), use a single JMAP batch request with ResultReferences
rather than two separate SessionClient calls.
All public async methods on SessionClient are cancel-safe at
each .await point: dropping the future before completion
releases the underlying reqwest request without poisoning the
connection pool. The server may still process the request (HTTP
is fire-and-forget on the wire); callers that care about
at-most-once semantics must enforce idempotency at the JMAP layer
(e.g. by sending a stable client-assigned creation key for
/set create operations).
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 chat_contact_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<ChatContact>, ClientError>
pub async fn chat_contact_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<ChatContact>, ClientError>
Fetch ChatContact objects by IDs (JMAP Chat §5 ChatContact/get).
If ids is None, returns all ChatContacts for the account.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- 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 chat_contact_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn chat_contact_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to ChatContact objects since since_state (RFC 8620 §5.2).
§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:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_contact_get.
Sourcepub async fn chat_contact_update(
&self,
id: &Id,
patch: &ChatContactPatch<'_>,
) -> Result<SetResponse, ClientError>
pub async fn chat_contact_update( &self, id: &Id, patch: &ChatContactPatch<'_>, ) -> Result<SetResponse, ClientError>
Update ChatContact properties (JMAP Chat §ChatContact/set).
Supports blocked (Boolean) and displayName (nullable String).
Create and destroy are not supported by spec; the server returns forbidden.
§Errors
ClientError::Parseif serializing the typeddisplay_nameClearable entry fails (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_contact_get. /set update errors appear inSetResponse::not_updatedrather than asErr.
Sourcepub async fn chat_contact_query(
&self,
input: &ChatContactQueryInput,
) -> Result<QueryResponse, ClientError>
pub async fn chat_contact_query( &self, input: &ChatContactQueryInput, ) -> Result<QueryResponse, ClientError>
Query ChatContact IDs with optional filter (JMAP Chat §ChatContact/query).
Supported filter keys: blocked, presence. Supported sort properties:
"lastSeenAt", "login", "lastActiveAt".
§Errors
ClientError::Parseif serializing the typedfilter_presenceenum orsort_propertyenum fails (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_contact_get. RFC 8620 §5.5 defines additional /query method-level errors (anchorNotFound,unsupportedFilter,unsupportedSort,tooManyChanges) that surface asMethodError.
Sourcepub async fn chat_contact_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 chat_contact_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 ChatContact since since_query_state
(RFC 8620 §5.6 / ChatContact/queryChanges).
filter and sort MUST match the filter / sort passed to the
original ChatContact/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::chat_contact_changes).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_contact_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 read_position_get(
&self,
ids: Option<&[Id]>,
) -> Result<GetResponse<ReadPosition>, ClientError>
pub async fn read_position_get( &self, ids: Option<&[Id]>, ) -> Result<GetResponse<ReadPosition>, ClientError>
Fetch ReadPosition objects by IDs (JMAP Chat §5 ReadPosition/get).
If ids is None, returns all ReadPosition records for the account.
The server creates one ReadPosition per Chat automatically.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- 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 read_position_update(
&self,
read_position_id: &Id,
last_read_message_id: &Id,
) -> Result<SetResponse, ClientError>
pub async fn read_position_update( &self, read_position_id: &Id, last_read_message_id: &Id, ) -> Result<SetResponse, ClientError>
Update the read position for a Chat (JMAP Chat §5 ReadPosition/set).
read_position_id is the server-assigned ReadPosition.id (from
read_position_get). last_read_message_id is the Message.id of the
most recent message read. The server updates lastReadAt and
recomputes Chat.unreadCount.
create and destroy are forbidden by the spec; only update is issued.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::read_position_get. /set update errors appear inSetResponse::not_updatedrather than asErr.
Sourcepub async fn presence_status_get(
&self,
) -> Result<GetResponse<PresenceStatus>, ClientError>
pub async fn presence_status_get( &self, ) -> Result<GetResponse<PresenceStatus>, ClientError>
Fetch the singleton PresenceStatus record (JMAP Chat §5 PresenceStatus/get).
Per spec there is exactly one PresenceStatus per account; ids: null
retrieves it.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::read_position_get.
Sourcepub async fn read_position_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn read_position_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to ReadPosition records since since_state (JMAP Chat §5 ReadPosition/changes).
max_changes may be None to let the server choose the limit (RFC 8620 §5.2).
§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:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::read_position_get.
Sourcepub async fn presence_status_update(
&self,
id: &Id,
patch: &PresenceStatusPatch<'_>,
) -> Result<SetResponse, ClientError>
pub async fn presence_status_update( &self, id: &Id, patch: &PresenceStatusPatch<'_>, ) -> Result<SetResponse, ClientError>
Update the PresenceStatus record (JMAP Chat §5 PresenceStatus/set).
Only update is issued; create and destroy are forbidden by the spec.
Fields absent from patch (i.e. Patch::Keep or None) are omitted from
the patch and left unchanged server-side.
§Errors
ClientError::Parseif serializing the typedpresenceenum or anyClearableentry (status_text,status_emoji,expires_at) fails (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::read_position_get. /set update errors appear inSetResponse::not_updatedrather than asErr.
Sourcepub async fn presence_status_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn presence_status_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to PresenceStatus records since since_state (JMAP Chat §5 PresenceStatus/changes).
max_changes may be None to let the server choose the limit (RFC 8620 §5.2).
§Errors
ClientError::InvalidArgumentifsince_stateis the empty string (defence-in-depth empty-state guard).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::read_position_get.
Sourcepub async fn push_subscription_create(
&self,
input: &PushSubscriptionCreateInput<'_>,
) -> Result<PushSubscriptionCreateResponse, ClientError>
pub async fn push_subscription_create( &self, input: &PushSubscriptionCreateInput<'_>, ) -> Result<PushSubscriptionCreateResponse, ClientError>
Create a PushSubscription with the optional chatPush extension
(RFC 8620 §7.2 / draft-atwood-jmap-chat-push-00 §3).
PushSubscriptions are account-independent: no accountId is included
in the request (RFC 8620 §7.2). When input.chat_push is Some, the
using array includes urn:ietf:params:jmap:chat:push (RFC 8620 §3.3:
capabilities MUST only be declared when used); otherwise urn:ietf:params:jmap:core
alone is used.
This method issues a create operation only. To extend expires, set
the verification code, change types, or update chatPush, use
push_subscription_update. To
unsubscribe, use push_subscription_destroy.
When input.client_id is None, a ULID is generated automatically.
§Errors
ClientError::InvalidArgumentifinput.device_client_idorinput.urlis empty (caller-precondition guards), or ifinput.chat_pushcarries duplicateaccountIdkeys in the slice.ClientError::Parseif serializing any typedChatPushConfigvalue fails (pathological conditions only).- Any transport / protocol variant returned by
JmapClient::call:Http,Parse,AuthFailed,MethodError(wraps RFC 8620 §3.6.2 method-level errors; servers that do not advertise thechatPushcapability returnunknownCapabilitywhen the input includes a chat-push sub-object),MethodNotFound,ResponseTooLarge, orUnexpectedResponse.
Note: push_subscription_* methods are not account-scoped (RFC
8620 §7.2) and therefore do NOT call session_parts(). The
session-derived account check that other Self::* methods make
before any wire call is skipped here; missing-account problems
surface only as transport / method-level errors from the server.
Sourcepub async fn push_subscription_update(
&self,
id: &Id,
patch: &PushSubscriptionPatch<'_>,
) -> Result<SetResponse, ClientError>
pub async fn push_subscription_update( &self, id: &Id, patch: &PushSubscriptionPatch<'_>, ) -> Result<SetResponse, ClientError>
Update a PushSubscription (RFC 8620 §7.2.2 PushSubscription/set update).
Issues a PushSubscription/set request with only the update sub-map
populated. RFC 8620 §7.2 declares url, keys, and deviceClientId
immutable; to change those, destroy the subscription and create a new
one. The patchable properties are exposed via PushSubscriptionPatch:
verificationCode, expires, types, and the JMAP Chat Push
extension’s chatPush.
PushSubscriptions are not account-scoped (RFC 8620 §7.2): no
accountId is sent. When the patch touches chat_push at all
(any non-Patch::Keep value), the using array includes
urn:ietf:params:jmap:chat:push; otherwise only
urn:ietf:params:jmap:core is declared (RFC 8620 §3.3).
§Errors
ClientError::InvalidArgumentifidis empty (defence-in-depth — typed&Iddoes not itself prevent empty values), or ifpatch.chat_pushisPatch::Setand the slice contains duplicateaccountIdkeys.ClientError::Parseif serializing theexpiresClearableentry or anyChatPushConfigvalue fails (pathological conditions only).- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::push_subscription_create. /set update errors appear inSetResponse::not_updatedrather than asErr.
Sourcepub async fn push_subscription_destroy(
&self,
ids: &[Id],
) -> Result<SetResponse, ClientError>
pub async fn push_subscription_destroy( &self, ids: &[Id], ) -> Result<SetResponse, ClientError>
Destroy one or more PushSubscriptions (RFC 8620 §7.2.2 PushSubscription/set destroy).
Issues a PushSubscription/set request with only the destroy array
populated. PushSubscriptions are not account-scoped (RFC 8620 §7.2):
no accountId is sent. Only urn:ietf:params:jmap:core is declared
— destroying never requires the chatPush capability since it is a
property-blind operation.
Clients SHOULD NOT destroy a PushSubscription they did not create —
RFC 8620 §7.2 reserves that to clients that recognise the
deviceClientId. This client does not enforce that rule; the server
may reject the call.
§Errors
ClientError::InvalidArgumentifidsis empty (a destroy call with no ids would be a no-op round-trip).- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::push_subscription_create. /set destroy errors appear inSetResponse::not_destroyedrather than asErr.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn space_ban_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<SpaceBan>, ClientError>
pub async fn space_ban_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<SpaceBan>, ClientError>
Fetch SpaceBan objects by IDs (JMAP Chat §4.18 SpaceBan/get).
If ids is None, returns all SpaceBan objects for the account.
Pass properties: None to return all fields.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- 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 space_ban_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn space_ban_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to SpaceBan objects since since_state (RFC 8620 §5.2 / SpaceBan/changes).
Only members with "ban" permission in the Space see all changes;
other members see changes to their own bans only.
§Errors
ClientError::InvalidArgumentifsince_stateis the empty string (defence-in-depth empty-state guard).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_ban_get.
Sourcepub async fn space_ban_create(
&self,
input: &SpaceBanCreateInput<'_>,
) -> Result<SetResponse, ClientError>
pub async fn space_ban_create( &self, input: &SpaceBanCreateInput<'_>, ) -> Result<SetResponse, ClientError>
Create a SpaceBan (RFC 8620 §5.3 / SpaceBan/set create).
When input.client_id is None, a ULID is generated automatically.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_ban_get. /set create errors (e.g.invalidProperties,forbidden) appear inSetResponse::not_createdrather than asErr.
Sourcepub async fn space_ban_destroy(
&self,
ids: &[Id],
) -> Result<SetResponse, ClientError>
pub async fn space_ban_destroy( &self, ids: &[Id], ) -> Result<SetResponse, ClientError>
Destroy SpaceBan objects (RFC 8620 §5.3 / SpaceBan/set destroy).
ids must be non-empty; the guard fires before any network call.
§Errors
ClientError::InvalidArgumentifidsis empty (caller-precondition guard).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_ban_get. /set destroy errors appear inSetResponse::not_destroyedrather than asErr.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn space_invite_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<SpaceInvite>, ClientError>
pub async fn space_invite_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<SpaceInvite>, ClientError>
Fetch SpaceInvite objects by IDs (JMAP Chat §4.17 SpaceInvite/get).
If ids is None, returns all SpaceInvite objects for the account.
Pass properties: None to return all fields.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- 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 space_invite_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn space_invite_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to SpaceInvite objects since since_state (RFC 8620 §5.2 / SpaceInvite/changes).
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 empty-state guard).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_invite_get.
Sourcepub async fn space_invite_create(
&self,
input: &SpaceInviteCreateInput<'_>,
) -> Result<SetResponse, ClientError>
pub async fn space_invite_create( &self, input: &SpaceInviteCreateInput<'_>, ) -> Result<SetResponse, ClientError>
Create a SpaceInvite (RFC 8620 §5.3 / SpaceInvite/set create).
When input.client_id is None, a ULID is generated automatically.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_invite_get. /set create errors (e.g.invalidProperties,forbidden) appear inSetResponse::not_createdrather than asErr.
Sourcepub async fn space_invite_destroy(
&self,
ids: &[Id],
) -> Result<SetResponse, ClientError>
pub async fn space_invite_destroy( &self, ids: &[Id], ) -> Result<SetResponse, ClientError>
Destroy SpaceInvite objects (RFC 8620 §5.3 / SpaceInvite/set destroy).
ids must be non-empty; the guard fires before any network call.
§Errors
ClientError::InvalidArgumentifidsis empty (caller-precondition guard).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_invite_get. /set destroy errors appear inSetResponse::not_destroyedrather than asErr.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn blob_lookup(
&self,
blob_ids: &[Id],
type_names: Option<&[&str]>,
) -> Result<BlobLookupResponse, ClientError>
pub async fn blob_lookup( &self, blob_ids: &[Id], type_names: Option<&[&str]>, ) -> Result<BlobLookupResponse, ClientError>
Reverse-lookup blobs: given a list of blob IDs and data type names, returns which objects of those types reference each blob.
Uses capability urn:ietf:params:jmap:blob2; the server MUST advertise
it in the Session for this method to succeed (RFC 8620 §3.3).
type_names filters which data types to search. None queries all
types registered on the server. For JMAP Chat, "Message" is the
expected type.
Security: blobs that are inaccessible or nonexistent are returned with
empty matchedIds arrays rather than an error (draft-ietf-jmap-blobext
§6), to avoid information leakage.
§Errors
ClientError::InvalidArgumentifblob_idsis empty (caller-precondition guard — a no-op lookup is never useful).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call:Http,Parse,AuthFailed,MethodError(wraps RFC 8620 §3.6.2 method-level errors; servers that do not advertiseurn:ietf:params:jmap:blob2returnunknownCapabilityhere),MethodNotFound,ResponseTooLarge, orUnexpectedResponse.
Sourcepub async fn blob_convert(
&self,
from_blob_id: &Id,
content_type: &str,
width: Option<u32>,
height: Option<u32>,
) -> Result<BlobConvertResponse, ClientError>
pub async fn blob_convert( &self, from_blob_id: &Id, content_type: &str, width: Option<u32>, height: Option<u32>, ) -> Result<BlobConvertResponse, ClientError>
Convert a blob to a different MIME type via an imageConvert recipe
(JMAP-BLOBEXT §8 / blob2 capability).
Typical use: request a thumbnail (image/webp) from an image blob
without downloading the original. The server MUST advertise
urn:ietf:params:jmap:blob2 in Session capabilities.
width and height are optional maximum-dimension hints; the server
may ignore or clamp them. Pass None to omit.
On success the converted blob is in
response.created[CALL_ID]. On failure the error is in
response.not_created[CALL_ID].
§Errors
ClientError::InvalidArgumentifcontent_typeis empty (caller-precondition guard — a conversion target without a MIME type is meaningless).ClientError::Parseif serializing the typedImageConvertRecipefails (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::blob_lookup. Per-creation failures (e.g.invalidArguments,unsupportedMediaType) appear inBlobConvertResponse::not_createdrather than asErr.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn custom_emoji_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<CustomEmoji>, ClientError>
pub async fn custom_emoji_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<CustomEmoji>, ClientError>
Fetch CustomEmoji objects by IDs (JMAP Chat §4.16 CustomEmoji/get).
If ids is None, returns all CustomEmoji objects visible to the account
(Space-specific and server-global).
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- 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 custom_emoji_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn custom_emoji_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to CustomEmoji objects since since_state
(RFC 8620 §5.2 / JMAP Chat §4.16 CustomEmoji/changes).
§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:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::custom_emoji_get.
Sourcepub async fn custom_emoji_create(
&self,
input: &CustomEmojiCreateInput<'_>,
) -> Result<SetResponse, ClientError>
pub async fn custom_emoji_create( &self, input: &CustomEmojiCreateInput<'_>, ) -> Result<SetResponse, ClientError>
Create a CustomEmoji (RFC 8620 §5.3 / JMAP Chat §4.16 CustomEmoji/set create).
When input.client_id is None, a ULID is generated automatically.
§Errors
ClientError::InvalidArgumentifinput.nameis empty (caller-precondition guard — emoji shortcodes require a non-empty name).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::custom_emoji_get. /set create errors (e.g.invalidProperties,forbidden,alreadyExists) appear inSetResponse::not_createdrather than asErr.
Sourcepub async fn custom_emoji_destroy(
&self,
ids: &[Id],
) -> Result<SetResponse, ClientError>
pub async fn custom_emoji_destroy( &self, ids: &[Id], ) -> Result<SetResponse, ClientError>
Destroy CustomEmoji objects (RFC 8620 §5.3 / JMAP Chat §4.16 CustomEmoji/set destroy).
ids must be non-empty; the guard fires before any network call.
§Errors
ClientError::InvalidArgumentifidsis empty (caller-precondition guard — a no-op destroy is never useful).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::custom_emoji_get. /set destroy errors appear inSetResponse::not_destroyedrather than asErr.
Sourcepub async fn custom_emoji_query(
&self,
input: &CustomEmojiQueryInput<'_>,
) -> Result<QueryResponse, ClientError>
pub async fn custom_emoji_query( &self, input: &CustomEmojiQueryInput<'_>, ) -> Result<QueryResponse, ClientError>
Query CustomEmoji IDs (RFC 8620 §5.5 / JMAP Chat §4.16 CustomEmoji/query).
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::custom_emoji_get. RFC 8620 §5.5 defines additional /query method-level errors (anchorNotFound,unsupportedFilter,unsupportedSort,tooManyChanges) that surface asMethodError.
Sourcepub async fn custom_emoji_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 custom_emoji_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 CustomEmoji since since_query_state
(RFC 8620 §5.6 / JMAP Chat §4.16 CustomEmoji/queryChanges).
filter and sort MUST match the filter / sort passed to the
original CustomEmoji/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::custom_emoji_changes).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::custom_emoji_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 quota_get(&self) -> Result<GetResponse<Quota>, ClientError>
pub async fn quota_get(&self) -> Result<GetResponse<Quota>, ClientError>
Fetch all Quota objects for the account (RFC 9425 §4.2 Quota/get).
Returns all quota records for the primary JMAP Chat account. Each
Quota includes used, hard_limit, and optional warn_limit fields
that callers can use to display storage bars and warnings.
The returned GetResponse::state token is preserved for
quota_changes delta-sync support.
Only call when crate::session::ChatSessionExt::supports_quotas
returns true.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- 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; servers that do not advertiseurn:ietf:params:jmap:quotareturnunknownCapability),MethodNotFound,ResponseTooLarge, orUnexpectedResponse.
Sourcepub async fn quota_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn quota_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Quota objects since since_state (RFC 8620 §5.2 / Quota/changes).
Returns ids of Quota objects created, updated, or destroyed since the
caller-supplied since_state token (typically the
GetResponse::state returned by an earlier
quota_get call).
If ChangesResponse::has_more_changes is true, call again with
ChangesResponse::new_state as since_state until the flag is
false.
max_changes caps the number of ids the server returns in a single
response; None lets the server choose. Servers are not required to
honour a max_changes hint exactly.
Only call when crate::session::ChatSessionExt::supports_quotas
returns true.
§Errors
ClientError::InvalidArgumentifsince_stateis the empty string (defence-in-depth —Stateconstructed viaState::fromaccepts empty strings, but an emptysinceStateis never useful).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::quota_get.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn chat_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<Chat>, ClientError>
pub async fn chat_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<Chat>, ClientError>
Fetch Chat objects by IDs (RFC 8620 §5.1 / JMAP Chat §Chat/get).
If ids is None, the server returns all Chats 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:chat.- 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 chat_query(
&self,
input: &ChatQueryInput,
) -> Result<QueryResponse, ClientError>
pub async fn chat_query( &self, input: &ChatQueryInput, ) -> Result<QueryResponse, ClientError>
Query Chat IDs with optional filter (RFC 8620 §5.5 / JMAP Chat §Chat/query).
Only keys that are Some in input are included in the filter object;
an empty filter object is sent as JSON null.
§Errors
ClientError::Parseif serializing the typedfilter_kindenum fails (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_get. RFC 8620 §5.5 defines additional /query method-level errors (anchorNotFound,unsupportedFilter,unsupportedSort,tooManyChanges) that surface asMethodError.
Sourcepub async fn chat_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn chat_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Chat objects since since_state (RFC 8620 §5.2 / Chat/changes).
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:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_get.
Sourcepub async fn chat_typing(
&self,
chat_id: &Id,
typing: bool,
) -> Result<TypingResponse, ClientError>
pub async fn chat_typing( &self, chat_id: &Id, typing: bool, ) -> Result<TypingResponse, ClientError>
Send a typing indicator for a Chat (JMAP Chat §Chat/typing).
Notifies other participants that the account is (or has stopped) typing.
The server silently drops the event if Chat.receiveTypingIndicators is
false for a recipient (direct/group chats); for channel chats the
preference has no effect. The server SHOULD rate-limit to one call per
account per chat per 3 seconds — excess calls MAY be silently discarded.
Debouncing (send once per keypress, stop event on idle) is the caller’s
responsibility.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_get.
Sourcepub async fn chat_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 chat_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 Chat since since_query_state
(RFC 8620 §5.6 / Chat/queryChanges).
Returns which Chat IDs were removed from or added to the query result set
since the given state. max_changes may be None.
filter and sort MUST match the filter / sort passed to the
original Chat/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::chat_changes).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_get. RFC 8620 §5.6 also definescannotCalculateChanges(returned when the server cannot honour the request given the supplied filter / sort); it surfaces asMethodError.
Sourcepub async fn chat_create(
&self,
input: &ChatCreateInput<'_>,
) -> Result<SetResponse, ClientError>
pub async fn chat_create( &self, input: &ChatCreateInput<'_>, ) -> Result<SetResponse, ClientError>
Create a Chat (JMAP Chat §Chat/set create).
Dispatches to the correct spec kind based on the input variant:
Direct or Group. When client_id inside the variant is None, a
ULID is generated automatically.
For Direct chats: if one already exists with the given contact_id,
the server returns it in SetResponse.updated rather than created
(dedup rule per spec).
Channel Chats are NOT created via Chat/set — per
draft-atwood-jmap-chat-00 §Chat (line 436) they are created via
Space/set with the addChannels patch key. Use
super::SessionClient::space_update with
super::SpacePatch::add_channels to create a Channel.
§Errors
ClientError::InvalidArgumentifinputis aGroupvariant with an emptyname(caller-precondition guard — Group chats require a non-empty display name).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_get. JMAP Chat-spec /set errors (invalidProperties,forbidden,overQuota, etc.) on a single creation appear inSetResponse::not_createdrather than asErr; only method-level failures surface asMethodError.
Sourcepub async fn chat_update(
&self,
id: &Id,
patch: &ChatPatch<'_>,
) -> Result<SetResponse, ClientError>
pub async fn chat_update( &self, id: &Id, patch: &ChatPatch<'_>, ) -> Result<SetResponse, ClientError>
Update Chat properties (JMAP Chat §Chat/set update).
Issues an update operation patching only the fields present in patch.
Use Patch::Set(v) to set nullable fields, Patch::Clear to null-clear
them, and Patch::Keep (default) to leave them unchanged. Slice fields
default to None for no-change.
If all fields are Keep/None, an empty patch is sent — RFC 8620 §5.3
permits this; the server treats it as a no-op but still returns the chat
in updated.
§Errors
ClientError::Parseif serializing a typed sub-field ofpatchfails — specifically aClearableentry’s value, a memberroleenum, or theupdate_member_rolesentries (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_get. JMAP Chat-spec /set update errors appear inSetResponse::not_updatedrather than asErr; only method-level failures surface asMethodError.
Sourcepub async fn chat_destroy(&self, ids: &[Id]) -> Result<SetResponse, ClientError>
pub async fn chat_destroy(&self, ids: &[Id]) -> Result<SetResponse, ClientError>
Destroy Chat objects (RFC 8620 §5.3 / Chat/set destroy).
Permanently removes the listed Chat IDs from the account.
ids must be non-empty; the guard fires before any network call.
§Errors
ClientError::InvalidArgumentifidsis empty (caller-precondition guard — a no-op destroy is never useful and would generate a wasted round-trip).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::chat_get. JMAP Chat-spec /set destroy errors appear inSetResponse::not_destroyedrather than asErr.
Source§impl SessionClient
impl SessionClient
Sourcepub async fn message_get(
&self,
ids: &[Id],
properties: Option<&[&str]>,
) -> Result<GetResponse<Message>, ClientError>
pub async fn message_get( &self, ids: &[Id], properties: Option<&[&str]>, ) -> Result<GetResponse<Message>, ClientError>
Fetch Message objects by IDs (RFC 8620 §5.1 / JMAP Chat §Message/get).
ids is required (non-empty); fetching all messages is impractical.
Pass properties: None to return all fields.
§Errors
ClientError::InvalidArgumentifidsis empty (caller-precondition guard — fetching all messages is impractical and explicitly disallowed).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- 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 message_query(
&self,
input: &MessageQueryInput<'_>,
) -> Result<QueryResponse, ClientError>
pub async fn message_query( &self, input: &MessageQueryInput<'_>, ) -> Result<QueryResponse, ClientError>
Query Message IDs within a Chat (RFC 8620 §5.5 / JMAP Chat §Message/query).
Per spec, either chat_id or has_mention: Some(true) must be provided.
Servers MUST return unsupportedFilter if neither condition holds.
Sort order is controlled by input.sort_ascending (default false =
newest first). With position:0, limit:N and sort_ascending:false, the
server returns the N most recent message IDs. Callers displaying messages
chronologically should set sort_ascending:true or reverse after fetching.
§Errors
ClientError::InvalidArgumentif neitherinput.chat_idnorinput.has_mention == Some(true)is provided (spec requires at least one to scope the query).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::message_get. RFC 8620 §5.5 defines additional /query method-level errors (anchorNotFound,unsupportedFilter,unsupportedSort,tooManyChanges) that surface asMethodError.
Sourcepub async fn message_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn message_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Message objects since since_state (RFC 8620 §5.2 / Message/changes).
§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:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::message_get.
Sourcepub async fn message_create(
&self,
input: &MessageCreateInput<'_>,
) -> Result<SetResponse, ClientError>
pub async fn message_create( &self, input: &MessageCreateInput<'_>, ) -> Result<SetResponse, ClientError>
Create (send) a new Message (RFC 8620 §5.3 / JMAP Chat §Message/set).
When input.client_id is None, a ULID is generated automatically.
The server maps the creation key to the server-assigned Message id in
SetResponse.created.
§Rate limiting
If the server rejects the message with error_type == "rateLimited" in
not_created, this method returns Err(ClientError::RateLimited) with
the retry_after timestamp from serverRetryAfter. If serverRetryAfter
is absent the method returns Err(ClientError::UnexpectedResponse).
§Return value
Returns Err(ClientError::RateLimited) when the server returns a rateLimited
set error with a serverRetryAfter field.
For all other server-side rejections (e.g., invalidProperties, forbidden),
this method returns Ok(set_resp) with the error recorded in
set_resp.not_created. Callers MUST inspect not_created on every Ok
response to confirm the message was actually created.
§Errors
ClientError::Parseif serializing the typedbody_typeenum fails (pathological conditions only).ClientError::RateLimitedif the server rejects the message witherror_type == "rateLimited"and supplies a validserverRetryAftertimestamp. Theretry_afterfield carries the server-supplied deadline.ClientError::UnexpectedResponseif the server emits arateLimitedSetError withoutserverRetryAfter, or with a malformed timestamp value.ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::message_get. All other per-creation failures (e.g.invalidProperties,forbidden) appear inSetResponse::not_createdon a successfulOkresponse (see the “Return value” note above).
Sourcepub async fn message_update(
&self,
id: &Id,
patch: &MessagePatch<'_>,
) -> Result<SetResponse, ClientError>
pub async fn message_update( &self, id: &Id, patch: &MessagePatch<'_>, ) -> Result<SetResponse, ClientError>
Update Message properties (RFC 8620 §5.3 / JMAP Chat §4.5 Message/set).
Issues an update operation patching only the fields present in patch.
Supports body edits (author-only), reaction changes (JSON Pointer patch on
reactions map), read-receipt updates (readAt), and chat-level deletion
(deletedAt / deletedForAll).
If all optional fields are None, an empty patch object is sent. RFC 8620
§5.3 permits this; the server treats it as a no-op but still returns the
object in updated.
§Errors
ClientError::InvalidArgumentif anyReactionChangeentry carries an emptysender_reaction_id, or one containing/or~(RFC 6901 JSON Pointer reserved characters that would misinterpret the patch path).ClientError::Parseif serializing the typedbody_typeorread_dispositionenums fails (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::message_get. /set update errors appear inSetResponse::not_updatedrather than asErr.
Sourcepub async fn message_destroy(
&self,
ids: &[Id],
) -> Result<SetResponse, ClientError>
pub async fn message_destroy( &self, ids: &[Id], ) -> Result<SetResponse, ClientError>
Destroy Message objects (RFC 8620 §5.3 / Message/set destroy).
Permanently removes the listed message IDs from the account.
ids must be non-empty; the guard fires before any network call.
§Errors
ClientError::InvalidArgumentifidsis empty (caller-precondition guard).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::message_get. /set destroy errors appear inSetResponse::not_destroyedrather than asErr.
Sourcepub async fn message_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 message_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 Message since since_query_state
(RFC 8620 §5.6 / Message/queryChanges).
Returns which message IDs were removed from or added to the query
result set since the given state. max_changes may be None.
filter and sort MUST match the filter / sort passed to the
original Message/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::message_changes).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::message_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 space_get(
&self,
ids: Option<&[Id]>,
properties: Option<&[&str]>,
) -> Result<GetResponse<Space>, ClientError>
pub async fn space_get( &self, ids: Option<&[Id]>, properties: Option<&[&str]>, ) -> Result<GetResponse<Space>, ClientError>
Fetch Space objects by IDs (RFC 8620 §5.1 / JMAP Chat §Space/get).
If ids is None, the server returns all Spaces 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:chat.- 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 space_changes(
&self,
since_state: &State,
max_changes: Option<u64>,
) -> Result<ChangesResponse, ClientError>
pub async fn space_changes( &self, since_state: &State, max_changes: Option<u64>, ) -> Result<ChangesResponse, ClientError>
Fetch changes to Space objects since since_state (RFC 8620 §5.2 / Space/changes).
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:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_get.
Sourcepub async fn space_destroy(
&self,
ids: &[Id],
) -> Result<SetResponse, ClientError>
pub async fn space_destroy( &self, ids: &[Id], ) -> Result<SetResponse, ClientError>
Destroy Space objects (RFC 8620 §5.3 / Space/set destroy).
Permanently removes the listed Space IDs from the account.
ids must be non-empty; the guard fires before any network call.
§Errors
ClientError::InvalidArgumentifidsis empty (caller-precondition guard).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_get. /set destroy errors appear inSetResponse::not_destroyedrather than asErr.
Sourcepub async fn space_query(
&self,
input: &SpaceQueryInput<'_>,
) -> Result<QueryResponse, ClientError>
pub async fn space_query( &self, input: &SpaceQueryInput<'_>, ) -> Result<QueryResponse, ClientError>
Query Space IDs with optional filter (RFC 8620 §5.5 / JMAP Chat §Space/query).
Only keys that are Some in input are included in the filter object;
an empty filter is sent as JSON null.
§Errors
ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_get. RFC 8620 §5.5 defines additional /query method-level errors (anchorNotFound,unsupportedFilter,unsupportedSort,tooManyChanges) that surface asMethodError.
Sourcepub async fn space_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 space_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 Space since since_query_state
(RFC 8620 §5.6 / Space/queryChanges).
Returns which Space IDs were removed from or added to the query result set
since the given state. max_changes may be None.
filter and sort MUST match the filter / sort passed to the
original Space/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::space_changes).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_get. RFC 8620 §5.6 also definescannotCalculateChanges(returned when the server cannot honour the request given the supplied filter / sort); it surfaces asMethodError.
Sourcepub async fn space_create(
&self,
input: &SpaceCreateInput<'_>,
) -> Result<SetResponse, ClientError>
pub async fn space_create( &self, input: &SpaceCreateInput<'_>, ) -> Result<SetResponse, ClientError>
Create a new Space (JMAP Chat §Space/set create).
When input.client_id is None, a ULID is generated automatically.
The server maps the creation key to the server-assigned Space id in
SetResponse.created.
§Errors
ClientError::InvalidArgumentifinput.nameis empty (caller-precondition guard — Space names cannot be empty).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_get. /set create errors (e.g.invalidProperties,forbidden,overQuota) appear inSetResponse::not_createdrather than asErr.
Sourcepub async fn space_join(
&self,
input: &SpaceJoinInput<'_>,
) -> Result<SpaceJoinResponse, ClientError>
pub async fn space_join( &self, input: &SpaceJoinInput<'_>, ) -> Result<SpaceJoinResponse, ClientError>
Join a Space via invite code or direct ID (JMAP Chat §Space/join).
input selects exactly one join path; the enum makes invalid inputs
unrepresentable at the type level.
§Errors
ClientError::InvalidArgumentifinputisSpaceJoinInput::InviteCode("")(empty code is never useful andId::new_validated("")is rejected at type construction for the other variant).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_get. Server-side rejections (invalidArgumentsfor unknown invite codes,forbiddenfor non-public Spaces) surface asMethodError.
Sourcepub async fn space_update(
&self,
id: &Id,
patch: &SpacePatch<'_>,
) -> Result<SetResponse, ClientError>
pub async fn space_update( &self, id: &Id, patch: &SpacePatch<'_>, ) -> Result<SetResponse, ClientError>
Update Space properties (JMAP Chat §Space/set update).
Issues an update operation patching only the fields present in patch.
Use Patch::Set(v) to set nullable fields, Patch::Clear to null-clear
them, and Patch::Keep (default) to leave them unchanged. Slice fields
default to None for no-change.
Supports the full set of semantic mutation keys from JMAP Chat §Space/set:
metadata (name, description, iconBlobId, isPublic,
isPubliclyPreviewable); members (addMembers, removeMembers,
updateMembers, manage_members); channels (addChannels,
removeChannels, updateChannels, manage_channels); roles
(addRoles, removeRoles, updateRoles, manage_roles); and
categories (addCategories, removeCategories, updateCategories,
manage_channels).
§Errors
ClientError::InvalidArgumentif any new channel, role, or category in the patch has an emptyname(caller-precondition guards onadd_channels,add_roles,add_categories).ClientError::Parseif serializing a typed sub-field (aClearableentry ondescription/icon_blob_id/update_*.*/ role color, a typedpermission_overridesvalue, etc.) fails (pathological conditions only).ClientError::InvalidSessionif the bound session has no primary account forurn:ietf:params:jmap:chat.- Any transport / protocol variant returned by
JmapClient::call— see the matching error list onSelf::space_get. /set update errors appear inSetResponse::not_updatedrather than asErr.
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 chat_account_id(&self) -> Result<&str, ClientError>
pub fn chat_account_id(&self) -> Result<&str, ClientError>
Return the primary account id for urn:ietf:params:jmap:chat,
or Err(InvalidSession) if the session has no primary account for
that capability.
§Errors
ClientError::InvalidSessionif the session has no primary account for the chat capability URI. This is the only failure mode — the method is a pure accessor on the captured session and does no network I/O.
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