simplejrpc 0.1.0

Unix-socket JSON-RPC 2.0 SDK with middleware, config, and validation
Documentation

simplejrpc

Unix-domain-socket JSON-RPC 2.0 SDK for Rust · Apache-2.0

Compatible in framing and app envelope with the Go simplejrpc-go library:

  • Transport: Unix socket + Content-Length frames (LSP / VS Code style)
  • App result envelope: { code, msg, data, meta } (business errors inside result, not JSON-RPC error)
  • Middleware (onion), JSON config, field validation, registration macros

Repo: DemonZack/simplejrpc-rust

Features

Area Details
Server / Client tokio async builders
Middleware request forward, response reverse
Errors typed Error, client-safe messages
Config JSON + test/dev/prod + dotted paths
Validation built-ins + custom Rule / rule_fn
Macros register_methods! / define_rpc_codes*! / validate_object!
Safety max frame body 16 MiB

Install

[dependencies]
simplejrpc = "0.1"

Or from Git:

[dependencies]
simplejrpc = { git = "https://github.com/DemonZack/simplejrpc-rust" }

Quick start

cargo test
cargo clippy --all-targets -- -D warnings
cargo run --example echo_server -- /tmp/simplejrpc.sock
# another terminal
cargo run --example echo_client -- /tmp/simplejrpc.sock

Server

use simplejrpc::{register_methods, Server};
use serde_json::json;

let server = register_methods!(Server::builder(), {
    "ping" => |_| async { Ok(json!("pong")) },
    "add" => |req| async move {
        Ok(json!(req.param_i64("a").unwrap_or(0) + req.param_i64("b").unwrap_or(0)))
    },
}).build();

server.serve("/tmp/simplejrpc.sock").await?;

Client

use simplejrpc::Client;
use serde_json::json;

let c = Client::connect("/tmp/simplejrpc.sock").await?;
let v = c.call("ping", json!({})).await?;

Layout

simplejrpc/
├── src/           # library
├── examples/      # echo server/client
├── tests/         # integration + optional Go interop
├── LICENSE        # Apache-2.0
├── CHANGELOG.md
└── CONTRIBUTING.md

Go interop (optional)

tests/cross_lang.rs builds a small Go bridge under tests/interop/go_bridge. Point replace in that go.mod at a local simplejrpc-go checkout. If Go or the replace path is missing, the test skips (does not fail CI).

MSRV

Rust 1.75+ (see rust-version in Cargo.toml).

License

Apache-2.0 — see LICENSE.