30 stable releases (12 major)

new 18.0.0 Jul 20, 2021
17.1.0 Jun 7, 2021
17.0.0 Jan 20, 2021
16.0.0 Dec 14, 2020
6.0.0 Feb 16, 2017
Download history 727/week @ 2021-04-03 1186/week @ 2021-04-10 895/week @ 2021-04-17 981/week @ 2021-04-24 720/week @ 2021-05-01 964/week @ 2021-05-08 1462/week @ 2021-05-15 1476/week @ 2021-05-22 784/week @ 2021-05-29 813/week @ 2021-06-05 663/week @ 2021-06-12 832/week @ 2021-06-19 702/week @ 2021-06-26 961/week @ 2021-07-03 1061/week @ 2021-07-10 1132/week @ 2021-07-17

4,114 downloads per month
Used in 9 crates (6 directly)

MIT license

130KB
3.5K SLoC

jsonrpc-tcp-server

TCP server for JSON-RPC 2.0.

Documentation

Example

Cargo.toml

[dependencies]
jsonrpc-tcp-server = "15.0"

main.rs

use jsonrpc_tcp_server::*;
use jsonrpc_tcp_server::jsonrpc_core::*;

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

	let server = ServerBuilder::new(io)
		.start(&"0.0.0.0:3030".parse().unwrap())
		.expect("Server must start with no issues");

	server.wait().unwrap()
}

lib.rs:

jsonrpc server over tcp/ip

use jsonrpc_core::*;
use jsonrpc_tcp_server::ServerBuilder;

fn main() {
    let mut io = IoHandler::default();
    io.add_sync_method("say_hello", |_params| {
        Ok(Value::String("hello".to_string()))
    });
    let server = ServerBuilder::new(io)
        .start(&"0.0.0.0:0".parse().unwrap())
        .expect("Server must start with no issues.");

    server.wait();
}

Dependencies

~8.5MB
~171K SLoC