Expand description
Wire protocol for the Spot real-time messaging network.
Each client establishes one or more websocket connections to spot servers. Packets are already encapsulated (known length), so every packet starts with a single byte carrying the protocol version (high 4 bits, currently 0) and the packet type (low 4 bits), followed by type-specific data:
0x0ping (C→S) / pong (S→C)0x1handshake request (S→C) or response (C→S), CBOR encoded0x2instant message, binary encoded
This crate is a Rust port of the Go package
github.com/KarpelesLab/spotproto
and is wire compatible with it.
Structs§
- Client
Id - A client identifier in the protocol, in the form
type.targetortype.server_id.target. - Handshake
Request - Handshake request, sent from server to client to initiate (or complete)
the handshake (packet type
0x1, S→C). CBOR map with fieldsrdy,srv,cid,rndandgrp. - Handshake
Response - Handshake response, sent from client to server (packet type
0x1, C→S). CBOR map with fieldsid,keyandsig. - Message
- An instant message exchanged between hosts (packet type
0x2).
Enums§
Constants§
- HANDSHAKE
- Handshake request or response packet type id.
- INSTANT_
MSG - Instant message packet type id.
- MSG_
FLAG_ ERROR - The message body contains an error string.
- MSG_
FLAG_ NOT_ BOTTLE - Body is not an encrypted bottle. Normally messages must be encrypted for
the recipient and signed by the sender using a
bottlers::Bottle, but some protocols skip this for efficiency or when payloads are already encrypted by another mechanism. - MSG_
FLAG_ RESPONSE - This is a response message that must not trigger further responses.
- PING_
PONG - Ping/pong keep-alive packet type id.
Functions§
- base64url_
decode - Decodes url-safe base64 without padding. Returns
Noneon invalid input. - base64url_
encode - Encodes bytes as url-safe base64 without padding.
- parse
- Decodes a raw buffer into the appropriate
Packet.is_clientindicates whether this is parsed on the client side, which decides how handshake packets are interpreted. - version_
and_ packet - Returns the version and packet id encoded in a packet’s first byte.