Rust RPC library built on top of [fibers] crate.
See [doc/].
Simple echo RPC server: ```rust use fibers::{Executor, InPlaceExecutor, Spawn}; use fibersrpc::{Call, ProcedureId}; use fibersrpc::client::RpcClientServiceBuilder; use fibersrpc::codec::BytesEncoder; use fibersrpc::server::{HandleCall, Reply, RpcServerBuilder}; use futures::Future;
// RPC definition struct EchoRpc; impl Call for EchoRpc { const ID: ProcedureId = ProcedureId(0); const NAME: &'static str = "echo";
type Req = Vec<u8>;
type ReqEncoder = BytesEncoder<Vec<u8>>;
type ReqDecoder = Vec<u8>;
type Res = Vec<u8>;
type ResEncoder = BytesEncoder<Vec<u8>>;
type ResDecoder = Vec<u8>;
}
// Executor let mut executor = InPlaceExecutor::new().unwrap();
// RPC server
struct EchoHandler;
impl HandleCall
// RPC client let service = RpcClientServiceBuilder::new().finish(executor.handle());
let request = Vec::from(&b"hello"[..]); let response = EchoRpc::client(&service.handle()).call(server_addr, request.clone());
executor.spawn(service.maperr(|e| panic!("{}", e))); let result = executor.runfuture(response).unwrap(); assert_eq!(result.ok(), Some(request)); ```
Informal benchmark result (v0.2.1):
```console $ uname -a Linux DESKTOP 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x8664 x8664 x86_64 GNU/Linux
$ lscpu | grep 'Model name:' Model name: Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
// Runs the example echo server in a shell. $ cargo run --example echo --release -- server
// Executes a benchmark command in another shell. $ echo "hello" | cargo run --example echo --release -- bench -c 1024 -n 1000000
```