rsrpc
Ergonomic Rust-to-Rust RPC where the trait is the API.
Overview
rsrpc generates RPC client and server code from a trait definition. The client implements the same trait as the server, so client.method(args) just works. No separate client types, no message enums, no schema files.
The macro generates:
impl Worker for Client<dyn Worker>- call methods directly on the client<dyn Worker>::serve(impl)- wrap any implementation in a server
Quick Start
use Result;
use ;
// Server implementation
;
async
Features
- Trait-based API: Define your service as a Rust trait
- Type-safe: Full compile-time type checking for all RPC calls
- Streaming: Methods returning
Result<RpcStream<T>>automatically stream - HTTP/REST: Annotate methods with
#[get],#[post], etc. for HTTP endpoints - Polymorphic: Generic code works with both local and remote implementations
HTTP/REST Support
Enable the http feature for REST endpoint support:
// Serve via HTTP
let router = http_routes;
serve.await?;
// Or use HTTP client
let client: = new;
client.get_user.await?;
License
MIT