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§
- Json
Frame - One WebSocket text frame. The frame kind is chosen by which of
message/half_close/status(or a baremetadataopen) is present. - Json
Status
Functions§
- decode_
json_ frame - Parse a WebSocket text frame.
- encode_
json_ frame - Serialize a
JsonFrameto a WebSocket text payload. - json_
frame_ to_ proto - Convert a post-open client
JsonFrame(WS text) into the internalFrame. The frame kind is chosen by which field is present. - json_
open_ to_ subscribe - Build a
Subscribefrom the open frame, taking the method from the WS route (the frame itself carries nomethod). - proto_
frame_ to_ json - Convert an internal server
Frameinto aJsonFramefor a WS text message. ReturnsNonefor kinds with no JSON form (client-only kinds).
Type Aliases§
- Json
Meta - Metadata as a JSON object (single value per key).