Skip to main content

NotificationHandler

Trait NotificationHandler 

Source
pub trait NotificationHandler<N: Notification>:
    Send
    + Sync
    + 'static
    + Send {
    type Error: Into<HexeractError> + Send + Sync + 'static;

    // Required method
    fn handle(
        &self,
        notification: Arc<N>,
        ctx: &HandlerContext,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

Asynchronous handler for a Notification.

Multiple handlers may be registered for the same notification type; the mediator delivers the notification to each of them. A handler failure does not interrupt the fan-out: every registered handler is invoked regardless of sibling outcomes.

Required Associated Types§

Source

type Error: Into<HexeractError> + Send + Sync + 'static

The handler-defined error type, convertible into HexeractError.

Required Methods§

Source

fn handle( &self, notification: Arc<N>, ctx: &HandlerContext, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Handles the notification.

The notification is shared across every registered handler as an Arc, so it is never deep-cloned per handler. Clone out of the Arc if an owned value is needed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§