pub struct EventBus { /* private fields */ }Expand description
Cloneable handle to the in-process bus. Cloning shares the same channels.
Implementations§
Source§impl EventBus
impl EventBus
pub fn new() -> Self
Sourcepub fn publish<E: Event>(&self, event: E) -> Result<usize, PublishError>
pub fn publish<E: Event>(&self, event: E) -> Result<usize, PublishError>
Publish an event. Returns the number of live subscribers that received it.
Publishing with no subscribers is not an error — a connector must not care whether anyone is listening.
Sourcepub fn subscribe<E: Event>(&self) -> Result<EventStream<E>, PublishError>
pub fn subscribe<E: Event>(&self) -> Result<EventStream<E>, PublishError>
Subscribe to every future event of type E.
Events published before subscribing are not replayed.
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