30个稳定版本 (12个主要版本)
18.0.0 | 2021年7月20日 |
---|---|
17.1.0 | 2021年6月7日 |
17.0.0 | 2021年1月20日 |
16.0.0 | 2020年12月14日 |
6.0.0 | 2017年2月16日 |
#1138 in 网络编程
546 每月下载次数
用于 6 crates
130KB
3.5K SLoC
jsonrpc-tcp-server
JSON-RPC 2.0的TCP服务器。
示例
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
:
基于tcp/ip的jsonrpc服务器
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();
}
依赖项
~8–22MB
~254K SLoC