pub struct EventBus { /* private fields */ }Expand description
Event bus for distributing events to handlers
Implementations§
Source§impl EventBus
impl EventBus
Sourcepub fn with_buffer_size(max_buffer_size: usize) -> Self
pub fn with_buffer_size(max_buffer_size: usize) -> Self
Create a new event bus with a custom buffer size
Sourcepub fn on(&mut self, handler: EventHandler)
pub fn on(&mut self, handler: EventHandler)
Register an event handler
Sourcepub fn emit(&mut self, event: OmegaEvent)
pub fn emit(&mut self, event: OmegaEvent)
Emit an event to all registered handlers
Sourcepub fn history(&self) -> &[OmegaEvent]
pub fn history(&self) -> &[OmegaEvent]
Get the event history buffer
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear the event history buffer
Sourcepub fn handler_count(&self) -> usize
pub fn handler_count(&self) -> usize
Get the number of registered handlers
Sourcepub fn filter_by_type(&self, event_type: &str) -> Vec<&OmegaEvent>
pub fn filter_by_type(&self, event_type: &str) -> Vec<&OmegaEvent>
Filter events by type
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventBus
impl !RefUnwindSafe for EventBus
impl Send for EventBus
impl Sync for EventBus
impl Unpin for EventBus
impl !UnwindSafe for EventBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more