extern crate jsonrpc_core;
#[macro_use]
extern crate jsonrpc_derive;
use jsonrpc_core::{Result, IoHandler};
#[rpc(server)]
pub trait Rpc {
#[rpc(name = "protocolVersion")]
fn protocol_version(&self) -> Result<String>;
#[rpc(name = "add", alias("callAsyncMetaAlias"))]
fn add(&self, a: u64, b: u64) -> Result<u64>;
}
struct RpcImpl;
impl Rpc for RpcImpl {
fn protocol_version(&self) -> Result<String> {
Ok("version1".into())
}
fn add(&self, a: u64, b: u64) -> Result<u64> {
Ok(a + b)
}
}
fn main() {
let mut io = IoHandler::new();
let rpc = RpcImpl;
io.extend_with(rpc.to_delegate())
}