6 releases (3 breaking)

0.4.0 Dec 7, 2018
0.3.0 Oct 15, 2018
0.2.0 Oct 11, 2018
0.1.2 Oct 5, 2018
0.1.1 Sep 28, 2018

#158 in Encoding

Download history 13/week @ 2018-10-24 41/week @ 2018-10-31 25/week @ 2018-11-07 28/week @ 2018-11-14 12/week @ 2018-11-21 41/week @ 2018-11-28 46/week @ 2018-12-05 29/week @ 2018-12-12 110/week @ 2018-12-19 4/week @ 2018-12-26 18/week @ 2019-01-02 14/week @ 2019-01-09 18/week @ 2019-01-16 5/week @ 2019-01-23 5/week @ 2019-01-30

163 downloads per month
Used in 10 crates (3 directly)

MIT license

90KB
2.5K SLoC

Parity JSON-RPC

Rust implementation of JSON-RPC 2.0 Specification. Transport-agnostic core and transport servers for http, ipc, websockets and tcp.

Build Status Build Status

Documentation

Sub-projects

Examples

Basic Usage (with HTTP transport)

extern crate jsonrpc_core;
extern crate jsonrpc_minihttp_server;

use jsonrpc_core::{IoHandler, Value, Params};
use jsonrpc_minihttp_server::{ServerBuilder};

fn main() {
	let mut io = IoHandler::new();
	io.add_method("say_hello", |_params: Params| {
		Ok(Value::String("hello".to_string()))
	});

	let server = ServerBuilder::new(io)
		.threads(3)
		.start_http(&"127.0.0.1:3030".parse().unwrap())
		.unwrap();

	server.wait().unwrap();
}

Basic usage with macros

extern crate jsonrpc_core;
#[macro_use]
extern crate jsonrpc_macros;

use jsonrpc_core::Result;

build_rpc_trait! {
	pub trait Rpc {
		/// Adds two numbers and returns a result
		#[rpc(name = "add")]
		fn add(&self, u64, u64) -> Result<u64>;
	}
}

pub struct RpcImpl;
impl Rpc for RpcImpl {
	fn add(&self, a: u64, b: u64) -> Result<u64> {
		Ok(a + b)
	}
}


fn main() {
	let mut io = jsonrpc_core::IoHandler::new();
	io.extend_with(RpcImpl.to_delegate())
}

Dependencies

~90KB