23 stable releases (9 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
0.1.0 Nov 5, 2018

#321 in HTTP server

Download history 1119/week @ 2024-07-20 961/week @ 2024-07-27 930/week @ 2024-08-03 801/week @ 2024-08-10 883/week @ 2024-08-17 907/week @ 2024-08-24 623/week @ 2024-08-31 1162/week @ 2024-09-07 1585/week @ 2024-09-14 427/week @ 2024-09-21 421/week @ 2024-09-28 522/week @ 2024-10-05 1179/week @ 2024-10-12 1435/week @ 2024-10-19 566/week @ 2024-10-26 597/week @ 2024-11-02

3,893 downloads per month
Used in 3 crates

MIT license

67KB
2K SLoC

jsonrpc-stdio-server

STDIN/STDOUT server for JSON-RPC 2.0. Takes one request per line and outputs each response on a new line.

Documentation

Example

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:

jsonrpc server using stdin/stdout


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;
}

Dependencies

~4–11MB
~106K SLoC