pub struct EventBus { /* private fields */ }Expand description
Event bus for component communication
Provides publish-subscribe messaging between components with event routing, subscription management, and event queuing for asynchronous processing.
Implementations§
Source§impl EventBus
impl EventBus
Sourcepub fn subscribe(
&mut self,
event_type: &str,
component_id: &str,
) -> SklResult<()>
pub fn subscribe( &mut self, event_type: &str, component_id: &str, ) -> SklResult<()>
Subscribe a component to an event type
Sourcepub fn unsubscribe(
&mut self,
event_type: &str,
component_id: &str,
) -> SklResult<()>
pub fn unsubscribe( &mut self, event_type: &str, component_id: &str, ) -> SklResult<()>
Unsubscribe a component from an event type
Sourcepub fn publish(&mut self, event: ComponentEvent) -> SklResult<()>
pub fn publish(&mut self, event: ComponentEvent) -> SklResult<()>
Publish an event to the bus
Sourcepub fn emit_event(&mut self, event: ComponentEvent) -> SklResult<()>
pub fn emit_event(&mut self, event: ComponentEvent) -> SklResult<()>
Emit an event (alias for publish for backward compatibility)
Sourcepub fn process_events(&mut self) -> SklResult<Vec<EventProcessingResult>>
pub fn process_events(&mut self) -> SklResult<Vec<EventProcessingResult>>
Process all queued events
Sourcepub fn register_handler(
&mut self,
event_type: &str,
handler: Box<dyn EventHandler>,
)
pub fn register_handler( &mut self, event_type: &str, handler: Box<dyn EventHandler>, )
Register an event handler
Sourcepub fn get_statistics(&self) -> &EventStatistics
pub fn get_statistics(&self) -> &EventStatistics
Get event statistics
Sourcepub fn get_subscribers(&self, event_type: &str) -> Vec<String>
pub fn get_subscribers(&self, event_type: &str) -> Vec<String>
Get subscribers for an event type
Sourcepub fn clear_queue(&mut self)
pub fn clear_queue(&mut self)
Clear all events from the queue
Sourcepub fn queue_size(&self) -> usize
pub fn queue_size(&self) -> usize
Get current queue size
Sourcepub fn configure_routing(&mut self, config: EventRoutingConfig)
pub fn configure_routing(&mut self, config: EventRoutingConfig)
Configure event routing
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> 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