Skip to main content

Module json_frame

Module json_frame 

Source
Expand description

Native-JSON WebSocket frame format for the +json codec.

JSON WebSocket messages are text frames carrying a flat object; you read which field is present to know the frame kind. One WebSocket carries exactly one stream, so the WS URL is the route — frames carry neither method nor a stream id (human-readable):

{ "metadata": {…}, "timeoutMillis": 5000 } // open (optional; metadata/deadline)
{ "message": {…} }                         // data message
{ "halfClose": true }                      // client done sending
{ "status": { "code": 0, "message": "" } } // terminal (trailer / reset)

The application message is a native JSON value (not base64 bytes). Proto mode uses binary frames (crate::frame).

Structs§

JsonFrame
One WebSocket text frame. The frame kind is chosen by which of message / half_close / status (or a bare metadata open) is present.
JsonStatus

Functions§

decode_json_frame
Parse a WebSocket text frame.
encode_json_frame
Serialize a JsonFrame to a WebSocket text payload.
json_frame_to_proto
Convert a post-open client JsonFrame (WS text) into the internal Frame. The frame kind is chosen by which field is present.
json_open_to_subscribe
Build a Subscribe from the open frame, taking the method from the WS route (the frame itself carries no method).
proto_frame_to_json
Convert an internal server Frame into a JsonFrame for a WS text message. Returns None for kinds with no JSON form (client-only kinds).

Type Aliases§

JsonMeta
Metadata as a JSON object (single value per key).