Expand description
MessagePack RPC envelope, framing, codec, peer and transports.
message: the msgpack-rpc envelope ([0, id, method, params]etc.).transport: length-prefixed framing and the stdio, pipe and in-memory transports, including stdout protection for plugins.PeerandConnection: a symmetric endpoint. Either side can send requests and notifications; incoming ones are dispatched through aRouter.
The wire format is specified in spec/wire.md.
use lsdocs_protocol::{notification, request};
use lsdocs_rpc::{Options, Router, transport};
let router = Router::new()
.notification::<notification::Log, _>(|params, _peer| {
eprintln!("plugin says: {}", params.message);
});
let (peer, connection) = lsdocs_rpc::connect(transport::memory().0, router, Options::default());
tokio::spawn(connection.run());
peer.request::<request::Shutdown>(&()).await?;Modules§
- message
- The msgpack-rpc envelope.
- trace
- Logs every frame as JSON when the
lsdocs_rpc::wiretracing target is enabled at TRACE level (what--trace-rpcturns on). - transport
- Byte streams a
Peerruns over, and how frames are cut from them.
Structs§
- Connection
- Drives a connection: reads and dispatches incoming messages and writes
outgoing ones. Created by
connect. - Error
Code - Error codes used in
RpcError::code. They follow JSON-RPC and LSP. - Options
- Settings for a connection.
- Peer
- One end of a connection. Cheap to clone; all clones share the connection.
- Router
- Handlers for incoming requests and notifications, keyed by method.
- RpcError
- An error sent in a response.
Enums§
Functions§
- connect
- Creates a connection over
transport. Returns thePeerfor sending and theConnectionthat must be run (usually spawned) for anything to happen.