Skip to main content

Crate protocol

Crate protocol 

Source
Expand description

Port of packages/protocol: the strict CBOR subset, 4-byte big-endian framing and the validated client/server envelopes of protocol version 8.

Re-exports§

pub use cbor::CborError;
pub use cbor::CborOptions;
pub use cbor::Value;
pub use cbor::decode_cbor;
pub use cbor::encode_cbor;
pub use framing::DEFAULT_MAX_FRAME_LENGTH;
pub use framing::FrameDecoder;
pub use framing::FrameError;
pub use framing::MAX_SERVER_FRAME_LENGTH;
pub use framing::encode_frame;
pub use message::ClientMessage;
pub use message::ClientMessageDecoder;
pub use message::PROTOCOL_VERSION;
pub use message::ProtocolError;
pub use message::ProtocolValidationError;
pub use message::RpcTarget;
pub use message::ServerMessage;
pub use message::ServerMessageDecoder;
pub use message::SessionTarget;
pub use message::encode_client_message;
pub use message::encode_server_message;
pub use message::is_server_id;
pub use message::is_supported_protocol_version;
pub use message::parse_client_message;
pub use message::parse_server_message;
pub use service::ServiceCall;
pub use service::parse_service_call;

Modules§

cbor
Strict, definite-length RFC 8949 subset used on the wire (port of src/cbor).
custom_types
The custom message types (role: custom, customType) the engine adds to a conversation: clients draw each as one line, the model sees its text.
framing
Length-prefixed framing: each payload is preceded by its unsigned 32-bit big-endian length.
handshake
The client side of the handshake (packages/client connection.ts #handleMessage while connecting): the client sends hello; the server’s first message must be its hello for the expected server ID, or a hello_error.
json
Service payloads are JSON on the CBOR wire. Both directions are total: a CBOR value JSON cannot hold reads as JSON.stringify writes the decoded JavaScript value (a byte string or a non-finite float is null, an integral float below 2^53 an integer, -0 is 0).
message
Validated protocol envelopes (port of protocol.ts and codec.ts).
names
The names both ends of a connection spell the same: the services the server and its session workers expose, and the error codes clients act on.
pi_message
Reading Pi message JSON ({role, content, ...}), whose content is a string or a list of blocks.
service
Chord parseServiceCall (packages/chord/src/services/wire.ts): the server rejects any request whose opaque call is not a strict service call before routing it.
sockets
A server directory’s socket file names: <serverId>.sock (the server’s address clients connect to), control-<serverId>.sock (its coordinator’s control socket) and server-<serverId>-<nonce>.sock (one generation’s endpoint).
watch
Lane-watch events: what a session’s lane publishes to its watchers (the TUI, the RPC stream, herdr, the daemon’s lane replica), one JSON object per event tagged by type. The session worker writes them from this enum and every watcher reads them back through WatchEvent::decode, so a field is named in one place.

Structs§

Route
A logical server reached at a Unix socket path: its coordinator’s public socket, or one generation’s endpoint.