Expand description
Content-Length framed JSON-RPC 2.0 codec.
This is the message framing used by JSON-RPC over stdio transports such as
the Model Context Protocol (MCP): each message is prefixed with a
Content-Length: N\r\n\r\n header followed by exactly N bytes of UTF-8
JSON body.
The framing codec (read_payload, write_message) is serializer
agnostic — it operates on raw strings. The JSON-RPC 2.0 envelope builders
(build_result_message, build_error_message, build_notification)
are parameterized over a JsonRpcSerializer so this crate does not depend
on any concrete JSON value type; the caller binds its own serializer.
Traits§
- Json
RpcSerializer - Abstraction over a JSON serializer so the JSON-RPC envelope builders do not depend on a concrete JSON value type.
Functions§
- build_
error_ message - Build a JSON-RPC 2.0 error message.
- build_
notification - Build a JSON-RPC 2.0 notification (no id, no response expected).
- build_
result_ message - Build a JSON-RPC 2.0 result message.
- read_
payload - Read a JSON-RPC payload from a buffered reader.
- write_
message - Write a Content-Length framed JSON-RPC message to a writer.