30 stable releases (12 major)

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

#1624 in Network programming

Download history 255/week @ 2024-07-20 140/week @ 2024-07-27 76/week @ 2024-08-03 90/week @ 2024-08-10 81/week @ 2024-08-17 78/week @ 2024-08-24 99/week @ 2024-08-31 73/week @ 2024-09-07 75/week @ 2024-09-14 184/week @ 2024-09-21 144/week @ 2024-09-28 112/week @ 2024-10-05 176/week @ 2024-10-12 212/week @ 2024-10-19 92/week @ 2024-10-26 89/week @ 2024-11-02

579 downloads per month
Used in 6 crates

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–18MB
~236K SLoC