pub trait Handler:
Send
+ Sync
+ 'static {
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
msg: CanonicalMessage,
) -> Pin<Box<dyn Future<Output = Result<Handled, HandlerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn handle_many<'life0, 'async_trait>(
&'life0 self,
msgs: Vec<CanonicalMessage>,
) -> Pin<Box<dyn Future<Output = Vec<Result<Handled, HandlerError>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn register_handler(
&self,
_type_name: &str,
_handler: Arc<dyn Handler>,
) -> Option<Arc<dyn Handler>> { ... }
}Expand description
A generic trait for handling messages (commands or events).
Handlers process an incoming message and can optionally return a new
message (e.g. a reply) via Handled::Publish, or acknowledge processing via Handled::Ack.
Required Methods§
fn handle<'life0, 'async_trait>(
&'life0 self,
msg: CanonicalMessage,
) -> Pin<Box<dyn Future<Output = Result<Handled, HandlerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
fn handle_many<'life0, 'async_trait>(
&'life0 self,
msgs: Vec<CanonicalMessage>,
) -> Pin<Box<dyn Future<Output = Vec<Result<Handled, HandlerError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".