#json-rpc-server #json-rpc #rpc-server #plugin-api #json-rpc-v2

lampo-jsonrpc

Crate that provides a plugin API to give the possibility to implement a plugin in Rust

1 unstable release

0.0.1-alpha.1 Dec 18, 2023

#21 in #rpc-server

Apache-2.0

24KB
491 lines

lampo-jsonrpc

Description

Minimal and full feature pure async JSON RPC 2.0 server implementation.

API Usage

Provide instructions on how to install your project. For example:

let path = "/tmp/tmp.sock";
let server = JSONRPCv2::new(Arc::new(DummyCtx), path).unwrap();
let _ = server.add_rpc("foo", |_: &DummyCtx, request| {
    Ok(serde_json::json!(request))
});
let res = server.add_rpc("secon", |_: &DummyCtx, request| {
    Ok(serde_json::json!(request))
});
assert!(res.is_ok(), "{:?}", res);

let handler = server.handler();
let worker = server.spawn();
let request = Request::<Value> {
    id: Some(0.into()),
    jsonrpc: String::from_str("2.0").unwrap(),
    method: "foo".to_owned(),
    params: serde_json::Value::Array([].to_vec()),
};

// Client-side code
let client_worker = std::thread::spawn(move || {
    // [Add your client-side code here, similar to the example provided]
});

Contributing

TODO

License

This project is licensed under the GNU General Public License v2.0 only. For more information, see LICENSE.

Dependencies

~1.5–2.5MB
~50K SLoC