strata_protocol/client
Client → server frames.
Wire shape:
{"v": 0, "kind": "join", "doc": "..."}
{"v": 0, "kind": "leave", "doc": "..."}
{"v": 0, "kind": "create", "doc": "...", "child": "...", "child_state": <opaque>, "state": <opaque>}
{"v": 0, "kind": "delete", "doc": "...", "child": "...", "state": <opaque>}
{"v": 0, "kind": "delta", "doc": "...", "state": <opaque CRDT JSON>}
{"v": 0, "kind": "presence_set", "doc": "...", "payload": <opaque>}
{"v": 0, "kind": "ping"}
Authentication is performed at WebSocket upgrade time via a ?token=
query parameter — there is no in-band auth frame.
ClientFrame
Section titled “ClientFrame”A frame sent by a client to the server.
CRDT payloads (ops, ctx, presence payload) are decoded as
Dynamic so callers can hand them directly to lattice's typed
JSON decoders without this package needing to depend on lattice.
pub type ClientFrame { Join(document_id: String) Leave(document_id: String) Create(document_id: String, child: String, child_state: dynamic.Dynamic, state: dynamic.Dynamic) Delete(document_id: String, child: String, state: dynamic.Dynamic) Delta(document_id: String, state: dynamic.Dynamic) PresenceSet(document_id: String, payload: dynamic.Dynamic) Ping}Functions
Section titled “Functions”create
Section titled “create”Encode a Create frame.
pub fn create( String, String, json.Json, json.Json) -> json.Jsondecode
Section titled “decode”Parse a JSON string into a ClientFrame.
pub fn decode(String) -> Result(ClientFrame, error.DecodeError)delete
Section titled “delete”Encode a Delete frame.
pub fn delete( String, String, json.Json) -> json.JsonEncode a Delta frame. state is the opaque CRDT JSON state
produced by the client's CRDT layer (typically or_map.to_json).
pub fn delta( String, json.Json) -> json.Jsonencode
Section titled “encode”Encode a typed ClientFrame back to JSON. Useful for proxying or
re-broadcasting decoded frames; round-trips with decode.
pub fn encode(ClientFrame) -> json.Jsonframe_decoder
Section titled “frame_decoder”Decoder that yields a Result(ClientFrame, DecodeError). The outer
Result represents JSON shape errors; the inner one represents
protocol-level errors (unknown kind, version mismatch).
pub fn frame_decoder() -> decode.Decoder(Result(ClientFrame, error.DecodeError))Encode a Join frame.
pub fn join(String) -> json.JsonEncode a Leave frame.
pub fn leave(String) -> json.JsonEncode a Ping frame.
pub fn ping() -> json.Jsonpresence_set
Section titled “presence_set”Encode a PresenceSet frame.
pub fn presence_set( String, json.Json) -> json.Json