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
3,893 downloads per month
Used in 3 crates
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.
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