#protocol #json #http #jsonrpc

jsonrpc

Rust support for the JSON-RPC 2.0 protocol

22 releases

0.9.0 Jul 30, 2018
0.8.0 Aug 30, 2016
0.7.6 Jun 14, 2016
0.7.4 Feb 26, 2016
0.6.2 Nov 23, 2015

#66 in Network programming

Download history 46/week @ 2018-09-13 36/week @ 2018-09-20 120/week @ 2018-09-27 96/week @ 2018-10-04 16/week @ 2018-10-11 129/week @ 2018-10-18 175/week @ 2018-10-25 54/week @ 2018-11-01 227/week @ 2018-11-08 182/week @ 2018-11-15 220/week @ 2018-11-22 236/week @ 2018-11-29 236/week @ 2018-12-06

331 downloads per month
Used in 3 crates (2 directly)

CC0 license

21KB
371 lines

Status

Rust JSONRPC Client

Rudimentary support for sending JSONRPC 2.0 requests and receiving responses.

To send a request which should retrieve the above structure, consider the following example code

extern crate jsonrpc;
extern crate serde;
#[macro_use] extern crate serde_derive;

#[derive(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".to_owned(), None, None);
    let request = client.build_request("getmystruct".to_owned(), vec![]);
    match client.send_request(&request).and_then(|res| res.into_result::<MyStruct>()) {
        Ok(mystruct) => // Ok!
        Err(e) => // Not so much.
    }
}


lib.rs:

Rust JSON-RPC Library

Rust support for the JSON-RPC 2.0 protocol.

Dependencies

~7.5MB
~201K SLoC