async/async.rs
1use tetsy_jsonrpc_core::futures::Future;
2use tetsy_jsonrpc_core::*;
3
4fn main() {
5 let mut io = IoHandler::new();
6
7 io.add_method("say_hello", |_: Params| {
8 futures::finished(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).wait().unwrap(), Some(response.to_owned()));
15}