async/async.rs
1use jsonrpc_core::*;
2
3fn main() {
4 futures_executor::block_on(async {
5 let mut io = IoHandler::new();
6
7 io.add_method("say_hello", |_: Params| async {
8 Ok(Value::String("Hello World!".to_owned()))
9 });
10
11 let request = r#"{"jsonrpc": "2.0", "method": "say_hello", "params": [42, 23], "id": 1}"#;
12 let response = r#"{"jsonrpc":"2.0","result":"hello","id":1}"#;
13
14 assert_eq!(io.handle_request(request).await, Some(response.to_owned()));
15 });
16}