pub trait Event:
Any
+ Send
+ Sync
+ Debug {
// Required method
fn as_any(&self) -> &dyn Any;
// Provided methods
fn type_id(&self) -> TypeId { ... }
fn event_name(&self) -> &'static str { ... }
}
Expand description
Core trait that all events must implement
This trait provides the foundation for type-safe event dispatch. All event types must implement this trait to be used with the dispatcher.
§Example
use mod_events::Event;
#[derive(Debug, Clone)]
struct UserRegistered {
user_id: u64,
email: String,
}
impl Event for UserRegistered {
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
Required Methods§
Provided Methods§
Sourcefn event_name(&self) -> &'static str
fn event_name(&self) -> &'static str
Returns the event name for debugging