#[rpc_client]
Available on crate feature
macros
only.Expand description
Implement RPC client methods automatically.
§Example
struct MyRpcClient {
// This field must have an `rpc` method:
// pub async fn rpc(&self, method: &str, params: &RawValue) -> Result<Value>
inner: jsonrpc_utils::HttpClient,
}
#[rpc_client]
impl MyRpcClient {
async fn sleep(&self, secs: u64) -> Result<u64>;
async fn value(&self) -> Result<u64>;
async fn add(&self, (x, y): (i32, i32), z: i32) -> Result<i32>;
// Override rpc method name.
#[rpc(name = "@ping")]
async fn ping(&self) -> Result<String>;
}
§Blocking Client
struct MyRpcClient {
// This field must have an `rpc` method:
// pub fn rpc(&self, method: &str, params: &RawValue) -> Result<Value>
inner: jsonrpc_utils::BlockingHttpClient,
}
#[rpc_client]
impl MyRpcClient {
fn sleep(&self, secs: u64) -> Result<u64>;
fn add(&self, (x, y): (i32, i32), z: i32) -> Result<i32>;
#[rpc(name = "@ping")]
fn ping(&self) -> Result<String>;
}