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
579 downloads per month
Used in 6 crates
130KB
3.5K
SLoC
jsonrpc-tcp-server
TCP server for JSON-RPC 2.0.
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