Show the crate…

3 stable releases

15.1.0 Mar 13, 2021
14.2.1 Mar 1, 2021

#11 in #server-builder

36 downloads per month
Used in 4 crates (3 directly)

MIT license

130KB
3.5K SLoC

tetsy-jsonrpc-tcp-server

TCP server for JSON-RPC 2.0.

Documentation

Example

Cargo.toml

[dependencies]
tetsy-jsonrpc-tcp-server = "14.2"

main.rs

use tetsy_jsonrpc_tcp_server::*;
use tetsy_jsonrpc_tcp_server::tetsy_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 tetsy_jsonrpc_core::*;
use tetsy_jsonrpc_tcp_server::ServerBuilder;

fn main() {
	let mut io = IoHandler::default();
	io.add_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

~10MB
~176K SLoC