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

#316 in HTTP server

Download history 894/week @ 2024-08-05 853/week @ 2024-08-12 861/week @ 2024-08-19 890/week @ 2024-08-26 611/week @ 2024-09-02 1810/week @ 2024-09-09 922/week @ 2024-09-16 463/week @ 2024-09-23 399/week @ 2024-09-30 708/week @ 2024-10-07 1063/week @ 2024-10-14 1363/week @ 2024-10-21 584/week @ 2024-10-28 582/week @ 2024-11-04 359/week @ 2024-11-11 414/week @ 2024-11-18

1,946 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