Crates.io | exonum_jsonrpc |
lib.rs | exonum_jsonrpc |
version | 0.5.1 |
source | src |
created_at | 2017-07-17 08:57:03.467371 |
updated_at | 2019-07-09 13:50:14.45213 |
description | Rust support for the JSON-RPC 1.0 protocol |
homepage | |
repository | https://github.com/exonum/jsonrpc |
max_upload_size | |
id | 23733 |
size | 22,027 |
Rudimentary support for sending JSONRPC 1.0 requests and receiving responses.
This library is based on rust-jsonrpc.
To send a request which should retrieve the above structure, consider the following example code
#[macro_use] extern crate jsonrpc;
#[macro_use] extern crate serde_derive;
extern crate serde;
#[derive(Serialize, Deserialize)]
struct MyStruct {
elem1: bool,
elem2: String,
elem3: Vec<usize>
}
fn main() {
// The two Nones are for user/pass for authentication
let mut client = jsonrpc::client::Client::new("example.org", None, None);
let request = client.build_request("getmystruct", vec![]);
match client.send_request(&request).and_then(|res| res.into_result::<MyStruct>()) {
Ok(mystruct) => // Ok!
Err(e) => // Not so much.
}
}