Skip to main content

rpc_method

Macro rpc_method 

Source
macro_rules! rpc_method {
    ($name:ident, $method_name:expr, $handler:expr) => { ... };
}
Expand description

Define a simple JSON-RPC method with automatic trait implementation

ยงUsage:

rpc_method!(PingMethod, "ping", |_params, id| {
    rpc_success!("pong", id)
});

rpc_method!(AddMethod, "add", |params, id| {
    let nums: Vec<i32> = serde_json::from_value(params.unwrap_or_default()).unwrap();
    rpc_success!(nums.iter().sum::<i32>(), id)
});