Skip to main content

notification

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(())
}))

Constructs a server-side workflow_rpc::server::Notification handler from a closure or expression, wrapping its body so it can handle inbound notifications from clients.