23个稳定版本 (9个主要版本)

18.0.0 2021年7月20日
17.1.0 2021年6月7日
17.0.0 2021年1月20日
16.0.0 2020年12月14日
0.1.0 2018年11月5日

#283 in HTTP服务器

Download history · Rust 包仓库 573/week @ 2024-03-13 · Rust 包仓库 511/week @ 2024-03-20 · Rust 包仓库 590/week @ 2024-03-27 · Rust 包仓库 723/week @ 2024-04-03 · Rust 包仓库 1072/week @ 2024-04-10 · Rust 包仓库 1144/week @ 2024-04-17 · Rust 包仓库 1265/week @ 2024-04-24 · Rust 包仓库 1511/week @ 2024-05-01 · Rust 包仓库 1127/week @ 2024-05-08 · Rust 包仓库 1781/week @ 2024-05-15 · Rust 包仓库 1875/week @ 2024-05-22 · Rust 包仓库 1482/week @ 2024-05-29 · Rust 包仓库 404/week @ 2024-06-05 · Rust 包仓库 695/week @ 2024-06-12 · Rust 包仓库 855/week @ 2024-06-19 · Rust 包仓库 1003/week @ 2024-06-26 · Rust 包仓库

3,216 每月下载量
3 crates 中使用

MIT 协议

67KB
2K SLoC

jsonrpc-stdio-server

JSON-RPC 2.0的STDIN/STDOUT服务器。每行接收一个请求,并将每个响应输出到新的一行。

文档

示例

Cargo.toml

[dependencies]
jsonrpc-stdio-server = "15.0"

main.rs

use jsonrpc_stdio_server::ServerBuilder;
use jsonrpc_stdio_server::jsonrpc_core::*;

fn main() {
	let mut io = IoHandler::default();
	io.add_method("say_hello", |_params| {
		Ok(Value::String("hello".to_owned()))
	});

	ServerBuilder::new(io).build();
}

lib.rs:

使用stdin/stdout的jsonrpc服务器


use jsonrpc_stdio_server::ServerBuilder;
use jsonrpc_stdio_server::jsonrpc_core::*;

#[tokio::main]
async fn main() {
    let mut io = IoHandler::default();
    io.add_sync_method("say_hello", |_params| {
        Ok(Value::String("hello".to_owned()))
    });

    let server = ServerBuilder::new(io).build();
    server.await;
}

依赖项

~4–6MB
~103K SLoC