Attribute Macro toy_rpc_macros::export_impl [−][src]
#[export_impl]
Expand description
“Export” methods in the impl block with #[export_method]
attribute. Methods without
the attribute will not be affected. This will also generate client stub.
When using with #[async_trait]
, place #[async_trait]
before #[export_macro]
.
Under the hood, this macro generates method handlers. This macro implements the
toy_rpc::util::RegisterService
trait, which returns the handler hashmap
when a service is registered on the server.
Note
- The default service name generated will be the same as the name of the struct.
Example - Export impl block
struct Abacus { }
#[export_impl] // This will give a default service name of "Abacus"
impl Abacus {
#[export_method]
async fn subtract(&self, args(i32, i32)) -> Result<i32, String> {
// ...
}
}