Macro notification

Source
notification!() { /* proc-macro */ }
Expand description

notification!() macro for declaration of RPC notification handlers

This macro simplifies creation of async notification handler closures supplied to the RPC notification interface. An async notification closure requires to be Boxed and its result must be Pinned, resulting in the following syntax:


interface.notification(MyOps::Notify,Box::new(Notification::new(|msg: MyMsg|
    Box::pin(
        async move {
            // ...
            Ok(())
        }
    )
)))

The notification macro adds the required Box and Pin syntax, simplifying the declaration as follows:

interface.notification(MyOps::Notify, notification!(|msg: MyMsg| async move {
    // ...
    Ok(())
}))