#[non_exhaustive]pub enum WsFrame {
StateChange(StateChange),
Response(JmapResponse),
RequestError(WsRequestError),
Unknown {
type_name: String,
raw: Value,
},
}Expand description
A parsed frame received from the JMAP WebSocket.
Marked #[non_exhaustive] because the spec may define additional
@type values in future revisions.
§Debug redaction
WsFrame has a hand-written std::fmt::Debug impl rather than
#[derive(Debug)] so the Unknown::raw field is
printed as [REDACTED] instead of being serialised verbatim. See the
field doc on Unknown.raw for the credential-leak class this guards
against (bd:JMAP-6r7c.5). Use the structured accessors on the frame
itself, not {:?}, when you need the raw value.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StateChange(StateChange)
RFC 8620 §7.1 StateChange — one or more object types have changed state; client must re-fetch the affected data types.
Response(JmapResponse)
RFC 8887 Response — reply to a JMAP request sent on this connection.
The RFC 8887 §4.3.3 requestId lands in
JmapResponse::extra; read it
with WsFrame::request_id.
RequestError(WsRequestError)
RFC 8887 §4.3.4 RequestError — a request-level Problem Details object (RFC 8620 §3.6.1) answering a request sent on this connection.
Unknown
Unrecognized @type — silently ignored per forward-compatibility rules
(RFC 8887 §4.3.1: clients SHOULD ignore unknown message types).
Also produced when a known type ("Response", "RequestError", or
"StateChange") fails to deserialize — type_name will be that name
in that case, which can signal server misbehavior or a schema version
mismatch. Callers that log unknown frames should check for these names.
Fields
type_name: StringValue of the @type field. Either an unrecognized message type
per RFC 8887 §4.3.1, or "Response" / "RequestError" /
"StateChange" when a known type failed to deserialize into its
typed variant.
raw: ValueRaw JSON object as received from the server, preserved for forward-compatibility diagnostics.
DO NOT log this field verbatim. Future or extension JMAP
WebSocket message types may carry credential-grade material —
push verification codes (RFC 8887 §7.2), federation handshake
tokens, session-rotation challenges, etc. — and a malformed
Response to a method like PushSubscription/get can echo a
verificationCode back into this field.
The enclosing WsFrame uses a hand-written Debug impl that
renders this field as [REDACTED] to neutralise the natural
{:?}-leaks-the-field failure mode (bd:JMAP-6r7c.5). For
operator logs, prefer logging type_name only, or apply a
project-specific redaction filter before passing raw to a
logging sink. See bd:JMAP-sc1b.98.
Implementations§
Source§impl WsFrame
impl WsFrame
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The requestId correlating this frame with the id passed to
WsSender::send_request (RFC 8887 §4.3.3, §4.3.4).
Returns None for StateChange and Unknown frames, and for a
Response or RequestError whose requestId is absent, null, or
not a string. The server MUST echo the id when the request carried
one, but sends null when it could not parse the request at all
(RFC 8887 §4.4 notJSON example).