pub struct MemoryEventBus<E>where
E: Event,{ /* private fields */ }Expand description
Subscription-order event bus for tests and single-process applications.
Publishing stops and returns the first handler error. It never silently logs and discards a failed handler invocation.
Implementations§
Source§impl<E> MemoryEventBus<E>where
E: Event,
impl<E> MemoryEventBus<E>where
E: Event,
Sourcepub fn subscribe(
&self,
handler: Arc<dyn EventHandler<E>>,
) -> SoapResult<SubscriptionId>
pub fn subscribe( &self, handler: Arc<dyn EventHandler<E>>, ) -> SoapResult<SubscriptionId>
Adds a handler.
Sourcepub fn unsubscribe(&self, id: SubscriptionId) -> SoapResult<bool>
pub fn unsubscribe(&self, id: SubscriptionId) -> SoapResult<bool>
Removes a handler and reports whether it existed.
Sourcepub fn subscriber_count(&self) -> SoapResult<usize>
pub fn subscriber_count(&self) -> SoapResult<usize>
Returns the number of current handlers.
Trait Implementations§
Source§impl<E> Debug for MemoryEventBus<E>where
E: Event,
impl<E> Debug for MemoryEventBus<E>where
E: Event,
Source§impl<E> Default for MemoryEventBus<E>where
E: Event,
impl<E> Default for MemoryEventBus<E>where
E: Event,
Source§impl<E> EventPublisher<E> for MemoryEventBus<E>where
E: Event,
impl<E> EventPublisher<E> for MemoryEventBus<E>where
E: Event,
Source§fn publish(&self, event: EventEnvelope<E>) -> BoxFuture<'_, SoapResult<()>>
fn publish(&self, event: EventEnvelope<E>) -> BoxFuture<'_, SoapResult<()>>
Publishes an event to the configured delivery mechanism.
Auto Trait Implementations§
impl<E> !Freeze for MemoryEventBus<E>
impl<E> RefUnwindSafe for MemoryEventBus<E>
impl<E> Send for MemoryEventBus<E>
impl<E> Sync for MemoryEventBus<E>
impl<E> Unpin for MemoryEventBus<E>
impl<E> UnsafeUnpin for MemoryEventBus<E>
impl<E> UnwindSafe for MemoryEventBus<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