Why yet another JSON-RPC client when there are plenty?
The goal is to build a tiny client library which can construct a high or low level RPC client with a couple of lines of code.
The library is perfect to write small code snippets for testing JSON-RPC servers but can be also used in production applications as well.
High-level client usage example
use ;
use Deserialize;
use Duration;
// Define a trait to map all RPC methods
// The structure MyClient is automatically created for the above trait with a method "new"
// the response structure for the full "login" method output
// create a low-level HTTP RPC client
let http_client = http_client.timeout;
// create the high-level client
let client = new;
let token = client.authenticate.unwrap;
dbg!;
let result: LoginResponse = client.login.unwrap;
dbg!;
Low-level client usage example
use ;
use ;
use Duration;
// create a low-level HTTP RPC client
let http_client = http_client.timeout;
// use it directly. the params can be any which implements Serialize, the
// repsonse can be any which implements Deserialize
let result: LoginResponse = http_client.call.unwrap;
MessagePack support
with "msgpack" crate feature an optional MessagePack RPC de/serialization can be enabled:
use ;
// create a low-level HTTP RPC client
let http_client = new;
// it can be used as a transport for high-level clients as well
// let client = MyClient::new(http_client);
What is not supported (yet?)
-
Bulk RPC requests
-
RPC requests with no reply required (with no ID)
-
Async in high-level clients