pub struct EventBus<E: Event> { /* private fields */ }Expand description
A bounded, typed, in-process publish/subscribe bus for event E.
This bus is constructor-injected and process-local. Use rskit-messaging
for broker-backed cross-process events.
Implementations§
Source§impl<E: Event> EventBus<E>
impl<E: Event> EventBus<E>
Sourcepub fn new(config: EventBusConfig) -> Self
pub fn new(config: EventBusConfig) -> Self
Create a new bounded bus.
Sourcepub fn publish(&self, event: E) -> AppResult<usize>
pub fn publish(&self, event: E) -> AppResult<usize>
Publish an event to all current subscribers.
Returns the number of subscribers that accepted the event. Publishing to
a bus with no subscribers succeeds and returns 0.
Sourcepub fn subscribe(&self) -> Subscriber<E>
pub fn subscribe(&self) -> Subscriber<E>
Register a new subscriber.
Trait Implementations§
Auto Trait Implementations§
impl<E> !RefUnwindSafe for EventBus<E>
impl<E> !UnwindSafe for EventBus<E>
impl<E> Freeze for EventBus<E>
impl<E> Send for EventBus<E>
impl<E> Sync for EventBus<E>
impl<E> Unpin for EventBus<E>
impl<E> UnsafeUnpin for EventBus<E>
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