Skip to main content

Crate jmap_websocket

Crate jmap_websocket 

Source
Expand description

JMAP over WebSocket, RFC 8887 (urn:ietf:params:jmap:websocket).

This is a support crate (workspace AGENTS.md §Support crates): no *-types or *-server crate depends on it, and a deployment opts in.

Always available, with no async runtime:

Feature server: server::Connection, a session driver that turns incoming text frames into jmap_server::Dispatcher calls and writes the answers and push notifications back, over any Stream and Sink of messages, so it fits axum, tokio-tungstenite or another stack. Also server::PushHub, an in-memory state-change source with pushState replay.

Feature tungstenite: tungstenite::serve runs a connection over a tokio-tungstenite WebSocketStream.

The authenticated HTTP request that opens the WebSocket, and the TLS under it (RFC 8887 §4.1, §5.1), are the deployment’s.

Re-exports§

pub use jmap_types;
pub use futures;server
pub use jmap_server;server
pub use tokio_tungstenite;tungstenite

Modules§

serverserver
The server side of RFC 8887: a per-connection session driver.
tungstenitetungstenite
Running a Connection over tokio-tungstenite.

Structs§

WebSocketCapability
The value of the CAPABILITY key in a Session’s capabilities (RFC 8887 §3).
WebSocketPushDisable
Turns off push notifications for the connection (RFC 8887 §4.3.5.3). Its only RFC property is @type.
WebSocketPushEnable
Turns on push notifications for the connection (RFC 8887 §4.3.5.2).
WsRequest
A JMAP Request sent over the WebSocket (RFC 8887 §4.3.2): an RFC 8620 §3.3 Request plus @type: "Request" and an optional client id.
WsRequestError
A request-level error sent over the WebSocket (RFC 8887 §4.3.4): an RFC 8620 §3.6.1 problem details object plus @type: "RequestError" and requestId.
WsResponse
A JMAP Response sent over the WebSocket (RFC 8887 §4.3.3): an RFC 8620 §3.4 Response plus @type: "Response" and requestId.
WsStateChange
A push notification sent over the WebSocket (RFC 8887 §4.3.5.1): an RFC 8620 §7.1 StateChange plus an optional pushState.

Enums§

ClientMessage
A message a client sends (RFC 8887 §4.3): “a single JMAP Request object …, JMAP WebSocketPushEnable object …, or JMAP WebSocketPushDisable object”.
ServerMessage
A message a server sends (RFC 8887 §4.3): “a single JMAP Response object, JSON Problem Details object, or JMAP StateChange object”.

Constants§

CAPABILITY
The JMAP capability URI of this extension (RFC 8887 §3, §6): the key of WebSocketCapability in the Session’s capabilities.
SUBPROTOCOL
The WebSocket subprotocol name (RFC 8887 §4.2, §6.1). The client MUST list it in Sec-WebSocket-Protocol, and the server’s reply MUST carry it for a JMAP connection to be established.

Functions§

offers_jmap
Whether a Sec-WebSocket-Protocol request header value lists the SUBPROTOCOL (RFC 8887 §4.2).