Expand description
MessagePack and the MessagePack-RPC envelope (request [0, msgid, method, params],
response [1, msgid, error, result], notification [2, method, params]), shared by the
server and the client.
The stream has no framing, so bytes are buffered (at most MAX_MESSAGE) and a message is
decoded only from a complete in-memory buffer: no length the peer announces can allocate
more than the bytes already received, and nesting stops at MAX_DEPTH.
Values map to JSON one-to-one where JSON can say them; binary becomes {"$bin": hex}, an
extension {"$ext": type, "hex": hex}, and a map whose keys are not strings uses each key’s
JSON text as its name. Those objects encode back to the same MessagePack.
Structs§
- Stream
- A stream of messages: buffered bytes and the reader they come from.
Enums§
- Rpc
- An RPC message, checked against the envelope.
Constants§
- IO_
TIMEOUT - Deadline for the rest of a message once its first byte has arrived.
- MAX_
DEPTH - Deepest nesting decoded.
- MAX_
MESSAGE - Largest single message either side accepts.
- NOTIFICATION
- REQUEST
- RESPONSE
Functions§
- decode
- Decode one value from the front of
buf:Ok(Some((value, used))),Ok(None)when the buffer holds only part of it,Errwhen it is malformed. - encode
- Encode a JSON value as MessagePack (the inverse of
decode’s mapping). - encode_
message - notification
- parse
- request
- response