pub struct EventBus { /* private fields */ }Expand description
A simple in-app event bus for decoupling components.
Components emit events via EventBus::emit and the main loop drains the
pending queue via EventBus::drain once per frame, forwarding them to
PluginManager::process_events.
External code can register read-only observers with EventBus::subscribe
to react to events without consuming them (e.g. event logging, metrics).
The pending queue is capped at [MAX_PENDING] entries. If full, the oldest
event is dropped to make room for the newest, ensuring the bus never grows
without bound.
Implementations§
Source§impl EventBus
impl EventBus
pub fn new() -> Self
Sourcepub fn subscribe(&mut self, f: EventSubscriber)
pub fn subscribe(&mut self, f: EventSubscriber)
Register a read-only observer that is called for every emitted event.
Subscribers are invoked synchronously inside EventBus::emit after the
event is pushed to the pending queue. They receive a shared reference and
cannot modify or consume the event.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EventBus
impl !Sync for EventBus
impl !UnwindSafe for EventBus
impl Freeze for EventBus
impl Send for EventBus
impl Unpin for EventBus
impl UnsafeUnpin 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
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>
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>
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