Macro jsonrpc_macros::metadata
[−]
[src]
macro_rules! metadata { () => { ... }; ( $( $sub_name: ident )+ ) => { ... }; }
Auto-generates an RPC trait from trait definition.
This just copies out all the methods, docs, and adds another
function to_delegate
which will automatically wrap each strongly-typed
function in a wrapper which handles parameter and output type serialization.
RPC functions may come in a couple forms: synchronous, async and async with metadata.
These are parsed with the custom #[rpc]
attribute, which must follow
documentation.
The #[rpc] attribute
Valid forms:
- #[rpc(name = "name_here")]
(a synchronous rpc function which should be bound to the given name)
- #[rpc(async, name = "name_here")]
(an async rpc function which should be bound to the given name)
- #[rpc(meta, name = "name_here")]
(an async rpc function with metadata which should be bound to the given name)
Synchronous function format:
fn foo(&self, Param1, Param2, Param3) -> Result<Out, Error>
.
Asynchronous RPC functions must come in this form:
`fn foo(&self, Param1, Param2, Param3) -> BoxFuture
Asynchronous RPC functions with metadata must come in this form:
`fn foo(&self, Self::Metadata, Param1, Param2, Param3) -> BoxFuture
Anything else will be rejected by the code generator.
The #[pubsub] attribute
Valid form: ```rust,ignore
[pubsub(name = "hello")] {
#[rpc(name = "hello_subscribe")]
fn subscribe(&self, Self::Metadata, pubsub::Subscriber
The attribute is used to create a new pair of subscription methods (if underlying transport supports that.)