jsonrpc_macros/lib.rs
1//! High level, typed wrapper for `jsonrpc_core`.
2//!
3//! Enables creation of "Service" objects grouping a set of RPC methods together in a typed manner.
4//!
5//! Example
6//!
7//! ```
8//! extern crate jsonrpc_core;
9//! #[macro_use] extern crate jsonrpc_macros;
10//! use jsonrpc_core::{IoHandler, Error, Result};
11//! use jsonrpc_core::futures::future::{self, FutureResult};
12//! build_rpc_trait! {
13//! pub trait Rpc {
14//! /// Returns a protocol version
15//! #[rpc(name = "protocolVersion")]
16//! fn protocol_version(&self) -> Result<String>;
17//!
18//! /// Adds two numbers and returns a result
19//! #[rpc(name = "add")]
20//! fn add(&self, u64, u64) -> Result<u64>;
21//!
22//! /// Performs asynchronous operation
23//! #[rpc(name = "callAsync")]
24//! fn call(&self, u64) -> FutureResult<String, Error>;
25//! }
26//! }
27//! struct RpcImpl;
28//! impl Rpc for RpcImpl {
29//! fn protocol_version(&self) -> Result<String> {
30//! Ok("version1".into())
31//! }
32//!
33//! fn add(&self, a: u64, b: u64) -> Result<u64> {
34//! Ok(a + b)
35//! }
36//!
37//! fn call(&self, _: u64) -> FutureResult<String, Error> {
38//! future::ok("OK".to_owned()).into()
39//! }
40//! }
41//!
42//! fn main() {
43//! let mut io = IoHandler::new();
44//! let rpc = RpcImpl;
45//!
46//! io.extend_with(rpc.to_delegate());
47//! }
48//! ```
49
50#![warn(missing_docs)]
51
52pub extern crate jsonrpc_core;
53pub extern crate jsonrpc_pubsub;
54extern crate serde;
55
56mod auto_args;
57mod delegates;
58mod util;
59
60pub mod pubsub;
61
62#[doc(hidden)]
63pub use auto_args::{WrapAsync, WrapMeta, WrapSubscribe};
64
65#[doc(hidden)]
66pub use serde::{de::DeserializeOwned, Serialize};
67
68pub use auto_args::Trailing;
69pub use delegates::IoDelegate;
70pub use util::to_value;