clightningrpc_plugin/
macros.rs

1//! macros module containing all the necessary macros to work with the plugin
2//! and register new RPC method/Hooks/Subscription.
3//!
4//! author: https://github.com/vincenzopalazzo
5
6#[macro_export]
7macro_rules! add_rpc {
8    ($plugin:expr, $method:ident) => {
9        let rpc = $method::new();
10        $plugin.add_rpc_method(
11            rpc.name.as_str(),
12            rpc.usage.as_str(),
13            rpc.description.as_str(),
14            rpc.clone(),
15        );
16    };
17}
18
19/// register_notification - give the possibility to register a notification
20#[macro_export]
21macro_rules! register_notification {
22    ($plugin:expr, $notification:ident) => {
23        let callback = $notification::new();
24        $plugin.register_notification(callback.on_event.as_str(), callback.clone());
25    };
26}
27
28/// emit a compiler error
29#[macro_export]
30macro_rules! error {
31    ($($msg:tt)*) => {{
32        let msg = format!($($msg)*);
33        PluginError::new(-1, &msg, None)
34    }};
35}
36
37pub use add_rpc;
38pub use error;
39pub use register_notification;