pub trait Event: Any + Send {
// Required methods
fn is_cancelled(&self) -> bool;
fn cancel(&mut self);
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
fn bus_kind(&self) -> BusKind;
}Expand description
Trait implemented by all game events.
Events carry domain data and support cancellation. The as_any
methods enable type erasure inside the EventBus — handlers
register for concrete types via TypeId, and the bus downcasts
during dispatch.
Not all events are cancellable. For non-cancellable events
(e.g., PlayerJoinedEvent), cancel() is a no-op and
is_cancelled() always returns false.
Required Methods§
Sourcefn is_cancelled(&self) -> bool
fn is_cancelled(&self) -> bool
Whether this event has been cancelled by a Validate handler.
Sourcefn cancel(&mut self)
fn cancel(&mut self)
Cancels this event. Process and Post handlers will be skipped.
Only meaningful during the Validate stage. Non-cancellable events ignore this call.
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Upcasts to &mut dyn Any for mutable type-erased dispatch.