Skip to main content

ShareableMessageHandler

Type Alias ShareableMessageHandler 

Source
pub type ShareableMessageHandler = TypedHandler<dyn Any>;
Expand description

Type alias for handlers that work with dynamically-typed messages.

This replaces the legacy MessageHandler trait with a unified handler type that supports both typed and dynamic dispatch through the same trait.

Aliased Type§

pub struct ShareableMessageHandler(pub Rc<dyn Handler<dyn Any>>);

Tuple Fields§

§0: Rc<dyn Handler<dyn Any>>

Implementations§

Source§

impl ShareableMessageHandler

Source

pub fn from_typed<T, F>(f: F) -> Self
where T: 'static, F: Fn(&T) + 'static,

Creates a handler from a typed closure that internally downcasts.

Use this when you need Any-based routing but want type-safe handling. The callback will only be invoked if the message downcasts successfully.

Source

pub fn from_any<F>(f: F) -> Self
where F: Fn(&dyn Any) + 'static,

Creates a handler from an Any-typed closure.