23 stable releases (9 major)

new 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

#26 in HTTP server

Download history 123/week @ 2021-04-04 120/week @ 2021-04-11 156/week @ 2021-04-18 47/week @ 2021-04-25 116/week @ 2021-05-02 56/week @ 2021-05-09 60/week @ 2021-05-16 67/week @ 2021-05-23 93/week @ 2021-05-30 110/week @ 2021-06-06 92/week @ 2021-06-13 68/week @ 2021-06-20 88/week @ 2021-06-27 80/week @ 2021-07-04 145/week @ 2021-07-11 168/week @ 2021-07-18

375 downloads per month
Used in 3 crates

MIT license

66KB
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

~5MB
~93K SLoC