Expand description
RFC 8620 base JMAP client: auth, session fetch, blob, SSE, and WebSocket.
Extension-specific clients (jmap-chat-client, jmap-mail-client) depend on this crate.
§Usage
let auth = BearerAuth::new("...")?;
let client = JmapClient::new(
DefaultTransport,
auth,
"https://jmap.example.com",
ClientConfig::default(),
)?;
let session = client.fetch_session().await?;§extra field equality and the serde_json/preserve_order feature (bd:JMAP-6r7c.43)
Every public deserializable struct in this crate carries an
extra: serde_json::Map<String, serde_json::Value> field per the
workspace extras-preservation policy (see workspace AGENTS.md). Several
of these structs also derive PartialEq / Eq so callers can write
assert_eq!(a, b) in tests and if state_a == state_b { ... } in
application code.
The derived PartialEq impl compares the extra field via
serde_json::Map’s PartialEq impl, whose semantics depend on a
third-party feature flag:
- Default (this workspace’s posture).
serde_json::Mapis BTreeMap-backed; equality is order-insensitive (keys are stored in lexicographic order regardless of insertion order). serde_json/preserve_orderenabled anywhere in the dep graph.serde_json::Mapswitches toIndexMap(insertion-order preserved); equality becomes order-sensitive.
Two values constructed with the same extra entries inserted in
different orders therefore compare EQUAL under the default
configuration and UNEQUAL under preserve_order. The feature flag is
a global toggle: any crate in the consumer’s dep graph that enables
preserve_order flips the semantics for every crate in the graph.
In-scope structs: BlobUploadResponse, Session,
AccountInfo, WebSocketCapability, and StateChange.
Workspace memory note: jmap-base-client (and the full workspace)
does NOT enable preserve_order. Consumers in the same posture get
deterministic == behaviour on extra. Consumers that enable
preserve_order elsewhere and need stable equality independent of
that flag should compare the serialised forms instead:
let a_json = serde_json::to_value(&a)?;
let b_json = serde_json::to_value(&b)?;
assert_eq!(a_json, b_json);Structs§
- Account
Info - Per-account metadata in a JMAP Session (RFC 8620 §2).
- Account
Name - The human-readable account name (RFC 8620 §2
namefield on the per-account object). - Auth
Header - Single HTTP
(name, value)header pair, returned byAuthProvider::auth_header(bd:JMAP-6r7c.62, bd:JMAP-6r7c.20). - Basic
Auth - HTTP Basic authentication (
Authorization: Basic <base64(username:password)>). - Bearer
Auth - Bearer-token authentication (
Authorization: Bearer <token>). - Blob
Download Stream - A blob body being downloaded, returned by
JmapClient::download_blob_stream. - Blob
Upload Response - Response body returned by a successful blob upload (RFC 8620 §6.1).
- Builder
Transport - Concrete
TransportConfigproduced byCustomTransportBuilder::build. - Client
Config - Per-client configuration for timeouts and body size limits.
- Custom
CaTransport - Custom CA trust root (DER-encoded). No
Authorizationheader is injected. - Custom
Transport Builder - Builder for a
TransportConfigwith multi-root trust chains and optional mTLS client certificate (bd:JMAP-6r7c.65). - Default
Transport - Standard reqwest client with a 10-second connect timeout; no custom TLS.
- Download
Blob Params - Parameters for
JmapClient::download_blob. - Download
Blob Session Params - Parameters for
JmapClient::download_blob_session(bd:JMAP-6r7c.64). - Http
Client - Opaque HTTP client returned by
TransportConfig::build_client(bd:JMAP-6r7c.36). - Http
Error - HTTP transport error reported by the underlying HTTP client.
- Invalid
Header Value Error - A header value (typically an authentication token) contained bytes that are not valid for an HTTP header.
- Jmap
Client - Auth-agnostic JMAP base HTTP client.
- Jmap
Request Builder - Fluent builder for multi-method
JmapRequestobjects. - JmapUrl
- A plain JMAP URL — no RFC 6570 template variables expected.
- Jmap
UrlTemplate - An RFC 6570 Level-1 URI template — requires variable substitution before use as a request URL.
- None
Auth - No authentication: no
Authorizationheader. - Parse
Error - JSON deserialize / parse error reported by the underlying JSON parser.
- Query
Params - The RFC 8620 §5.5
/queryarguments shared by everyFoo/querymethod: which window of the result list to return and whether to compute the total. - Serialize
Error - JSON serialize error reported by the underlying JSON serializer.
- Session
- JMAP Session object returned by
GET /.well-known/jmap(RFC 8620 §2). - SseFrame
- A parsed SSE frame: the event and the
id:line value (if any). - SseReconnect
Policy - Backoff policy for
JmapClient::subscribe_events_reconnecting. - State
Change - A state change push notification (RFC 8620 §7.1).
- Subscribe
Events Session Params - Parameters for
JmapClient::subscribe_events_session(bd:JMAP-6r7c.64). - Upload
Blob Params - Parameters for
JmapClient::upload_blob. - Upload
Blob Session Params - Parameters for
JmapClient::upload_blob_session(bd:JMAP-6r7c.64). - Upload
Blob Stream Params - Parameters for
JmapClient::upload_blob_stream. - Username
- The authenticated user’s username (RFC 8620 §2
usernamefield). - WebSocket
Capability - Capability object for
"urn:ietf:params:jmap:websocket"(RFC 8887). - WebSocket
Error - WebSocket transport error reported by the underlying WebSocket client.
- WsReceiver
- Owning receive-half of a WebSocket connection (bd:JMAP-6r7c.31).
- WsRequest
Error - A request-level error received over WebSocket (RFC 8887 §4.3.4).
- WsSender
- Owning send-half of a WebSocket connection (bd:JMAP-6r7c.31).
- WsSession
- An established JMAP WebSocket session (RFC 8887).
Enums§
- Client
Error - Errors produced by the base JMAP client.
- Close
After - The RFC 8620 §7.3
closeafterevent-source variable, which “MUST be one of” these two values. - Http
Error Kind - Classification of an
HttpErrorreturned byHttpError::kind. - Parse
Category - Classification of a
ParseError/SerializeErrorfailure. - SseEvent
- A parsed SSE event from a JMAP event source (RFC 8620 §7.3).
- WebSocket
Error Kind - Classification of a
WebSocketErrorreturned byWebSocketError::kind. - WsFrame
- A parsed frame received from the JMAP WebSocket.
Constants§
- DEFAULT_
WS_ MAX_ MESSAGE_ BYTES - Maximum WebSocket message size (1 MiB), consistent with the SSE frame limit.
Prevents a misbehaving or hostile server from forcing the client to buffer
large messages over the event connection.
Default per-message / per-frame byte cap for WebSocket connections opened
via
connect_ws(which does not take a limit parameter). Callers that need a different cap should useconnect_ws_with_limitor thecrate::JmapClient::connect_ws_sessionconvenience method which reads themax_ws_messagefield fromClientConfig. Default: 1 MiB.
Traits§
- Auth
Provider - Injects per-request authentication credentials.
- Transport
Config - Controls how the underlying
HttpClientis constructed.
Functions§
- connect_
ws - Open a JMAP WebSocket connection (RFC 8887).
- connect_
ws_ allow_ plaintext - Establish a WebSocket connection that also accepts plaintext
ws://. - connect_
ws_ with_ limit - Establish a WebSocket connection with an explicit per-message / per-frame byte cap.
- expand_
url_ template - Expand a RFC 6570 Level-1 URI template by substituting variables.
- extract_
response - Find the method response matching
call_idinrespand deserialize its arguments intoT. - method_
error_ details - Return the full JMAP
"error"object forcall_id, including any properties beyondtypeanddescription. - parse_
sse_ block - Parse a single SSE block (the text between two blank lines) into an
SseFrame. - to_args
- Serialize a method argument to a
serde_json::Valuefor a JMAP method call’sargumentsobject. - upload_
body_ from_ reader - Wrap a
tokio::io::AsyncRead(a file, a pipe, a decompressor) as aBlobUploadBody. The reader is read in chunks as the request body is sent; it is never buffered whole.
Type Aliases§
- Blob
Upload Body - Request body for
JmapClient::upload_blob_stream: a stream of byte chunks sent to the server in order.