pub struct EventBus { /* private fields */ }Expand description
Event publisher held by the embed runtime.
EventBus is a thin wrapper around a
tokio::sync::broadcast::Sender that drops events silently
when no receivers are attached.
Implementations§
Source§impl EventBus
impl EventBus
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Build a fresh bus with the supplied channel capacity.
§Examples
use dynomite::embed::events::EventBus;
let bus = EventBus::new(8);
assert_eq!(bus.subscriber_count(), 0);Sourcepub fn subscribe(&self) -> EventStream
pub fn subscribe(&self) -> EventStream
Subscribe a fresh receiver.
§Examples
use dynomite::embed::events::EventBus;
let bus = EventBus::new(4);
let _rx = bus.subscribe();
assert!(bus.subscriber_count() >= 1);Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Number of attached 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 UnsafeUnpin 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