nanorpc
implements a subset of JSON-RPC 2.0, notably with the lack of no-response "notifications" and lack of negative-value error codes.
The most interesting part of nanorpc
is that it contains a derive macro, #[nanorpc]
, that given a trait that describes the server-side behavior of an RPC service, derives both raw JSON-RPC handlers and a client implementation:
```rust
pub trait MathProtocol { /// Adds two numbers async fn add(&self, x: f64, y: f64) -> f64; /// Multiplies two numbers async fn mult(&self, x: f64, y: f64) -> f64; }
// Autogenerates a server struct:
pub struct MathService
impl
// Autogenerates a client struct like:
pub struct MathClient
impl
//...
} ```
Note: right now the library is NOT done. Do not attempt to use it yet, the above is just a sketch of what it will do.