pub struct BroadcastBus<E> { /* private fields */ }Expand description
A typed publish/subscribe bus that broadcasts each event to all subscribers.
Every handle can both publish and receive. Use subscribe
to add an independent consumer; an event published after a handle subscribes
is delivered to it. A subscriber only sees events published after it
subscribed, mirroring a live pub/sub channel.
§Examples
use pamoja_core::EventBus;
use pamoja_bus::BroadcastBus;
let bus = BroadcastBus::new(16);
let mut subscriber = bus.subscribe();
bus.publish("reading").await?;
assert_eq!(subscriber.next_event().await?, Some("reading"));Implementations§
Trait Implementations§
Source§impl<E: Clone> EventBus for BroadcastBus<E>
impl<E: Clone> EventBus for BroadcastBus<E>
Auto Trait Implementations§
impl<E> Freeze for BroadcastBus<E>
impl<E> RefUnwindSafe for BroadcastBus<E>
impl<E> Send for BroadcastBus<E>where
E: Send,
impl<E> Sync for BroadcastBus<E>where
E: Send,
impl<E> Unpin for BroadcastBus<E>
impl<E> UnsafeUnpin for BroadcastBus<E>
impl<E> UnwindSafe for BroadcastBus<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