use std::fmt::Debug; use crate::context::Context; /// A trait for types that can handle reception of a message. /// /// Message types are mapped to handler types by Dispatcher. /// This trait is intended to allow composing handler logic. pub trait MessageHandler: Debug { type Message; /// Attempts to handle the given message against the given context. fn run( self, context: &mut Context, message: &Self::Message, ) -> anyhow::Result<()>; /// Returns the name of this handler type. fn name() -> String; }