[−][src]Crate susy_jsonrpc_macros
High level, typed wrapper for susy_jsonrpc_core
.
Enables creation of "Service" objects grouping a set of RPC methods together in a typed manner.
Example
extern crate susy_jsonrpc_core; #[macro_use] extern crate susy_jsonrpc_macros; use susy_jsonrpc_core::{IoHandler, Error, Result}; use susy_jsonrpc_core::futures::future::{self, FutureResult}; build_rpc_trait! { pub trait Rpc { /// Returns a protocol version #[rpc(name = "protocolVersion")] fn protocol_version(&self) -> Result<String>; /// Adds two numbers and returns a result #[rpc(name = "add")] fn add(&self, u64, u64) -> Result<u64>; /// Performs asynchronous operation #[rpc(name = "callAsync")] fn call(&self, u64) -> FutureResult<String, Error>; } } 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 call(&self, _: u64) -> FutureResult<String, Error> { future::ok("OK".to_owned()).into() } } fn main() { let mut io = IoHandler::new(); let rpc = RpcImpl; io.extend_with(rpc.to_delegate()); }
Re-exports
pub extern crate susy_jsonrpc_core; |
pub extern crate susy_jsonrpc_pubsub; |
Modules
pubsub | PUB-SUB auto-serializing structures. |
Macros
build_rpc_trait | Build an RPC trait definition. |
metadata | Auto-generates an RPC trait from trait definition. |
Structs
IoDelegate | A set of RPC methods and notifications tied to single |
Trailing | A wrapper type without an implementation of |
Functions
to_value | Converts a serializable value into |