pub struct EventBus { /* private fields */ }Expand description
Multi-subscriber event bus.
Events sent to this bus are broadcast to all subscribers. Uses tokio’s broadcast channel for fan-out delivery.
Implementations§
Source§impl EventBus
impl EventBus
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new event bus.
Spawns a background task to forward events from the mpsc channel to the broadcast channel.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new event bus with a specific broadcast capacity.
Sourcepub fn sender(&self) -> EventSender
pub fn sender(&self) -> EventSender
Get a sender for submitting events to the bus.
Sourcepub fn subscribe(&self) -> EventReceiver
pub fn subscribe(&self) -> EventReceiver
Subscribe to events from this bus.
Returns a receiver that will receive all events sent to the bus after this subscription is created.
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Get the number of active subscribers.
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