pub struct EventBus { /* private fields */ }Expand description
Typed event bus for broadcasting RuntimeEvent instances.
Implementations§
Source§impl EventBus
impl EventBus
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new event bus with a specific capacity.
Sourcepub fn publish(&self, event: RuntimeEvent)
pub fn publish(&self, event: RuntimeEvent)
Publish a typed event to all subscribers.
Sourcepub fn emit(&self, event_type: &str, source: &str, data: Value)
pub fn emit(&self, event_type: &str, source: &str, data: Value)
Convenience: publish a legacy Event by converting it to RuntimeEvent::Custom.
Sourcepub fn subscribe(&self) -> Receiver<RuntimeEvent>
pub fn subscribe(&self) -> Receiver<RuntimeEvent>
Subscribe to all events (unfiltered).
Sourcepub fn subscribe_topics(&self, topics: HashSet<EventTopic>) -> TopicSubscriber
pub fn subscribe_topics(&self, topics: HashSet<EventTopic>) -> TopicSubscriber
Subscribe with topic-based filtering (#94).
The returned TopicSubscriber only yields events whose topic is in
the given set.
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
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 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