Skip to main content

IntoHandler

Trait IntoHandler 

Source
pub trait IntoHandler<T>: 'static {
    // Required methods
    fn id(&self) -> Ustr;
    fn handle(&self, message: T);
}
Expand description

Compile-time type-safe message handler trait that takes ownership.

Unlike Handler<T> which borrows messages, this trait takes ownership of messages, enabling zero-copy processing when the handler needs to store or forward the message.

Required Methods§

Source

fn id(&self) -> Ustr

Returns the unique identifier for this handler.

Source

fn handle(&self, message: T)

Handles a message of type T, taking ownership.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T, H: IntoHandler<T>> IntoHandler<T> for Rc<H>

Source§

fn id(&self) -> Ustr

Source§

fn handle(&self, message: T)

Implementors§

Source§

impl<T: 'static, F: Fn(T) + 'static> IntoHandler<T> for IntoCallbackHandler<T, F>

Source§

impl<T: 'static> IntoHandler<T> for TypedIntoMessageSavingHandler<T>