Skip to main content

MessageHandler

Trait MessageHandler 

Source
pub trait MessageHandler {
    type Interface: Interface;

    // Required method
    fn handle_message(
        &self,
        message: Self::Interface,
    ) -> impl Future<Output = ()> + Send;

    // Provided method
    fn name() -> &'static str { ... }
}
Expand description

Basic building block for composing services.

Required Associated Types§

Source

type Interface: Interface

The message interface (see Service::Interface).

Required Methods§

Source

fn handle_message( &self, message: Self::Interface, ) -> impl Future<Output = ()> + Send

The asynchronous message handler for this service.

Provided Methods§

Source

fn name() -> &'static str

The name of the message handler.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: MessageHandler + ?Sized> MessageHandler for Arc<T>

Source§

type Interface = <T as MessageHandler>::Interface

Source§

fn handle_message( &self, message: Self::Interface, ) -> impl Future<Output = ()> + Send

Source§

fn name() -> &'static str

Implementors§