1 stable release
Uses old Rust 2015
8.0.0 | May 14, 2019 |
---|
#11 in #server-builder
Used in 2 crates
110KB
2.5K
SLoC
rs-jsonrpc-tcp-server
TCP server for JSON-RPC 2.0.
Example
Cargo.toml
[dependencies]
rs-jsonrpc-core = "6.0"
rs-jsonrpc-tcp-server = "6.0"
main.rs
extern crate rs_jsonrpc_core;
extern crate rs_jsonrpc_tcp_server;
use rs_jsonrpc_core::*;
use rs_jsonrpc_tcp_server::*;
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
extern crate rs_jsonrpc_core;
extern crate rs_jsonrpc_tcp_server;
use rs_jsonrpc_core::*;
use rs_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
~12MB
~210K SLoC