pub struct MessageBus { /* private fields */ }Expand description
Broadcast-based message bus for inter-agent communication.
Agents subscribe to the bus and receive messages addressed to them or broadcast messages. Thread-safe and async-compatible.
Implementations§
Source§impl MessageBus
impl MessageBus
Sourcepub fn publish(&self, msg: InterAgentMessage) -> PublishResult
pub fn publish(&self, msg: InterAgentMessage) -> PublishResult
Publish a message to the bus.
Returns a PublishResult indicating how many receivers received the
message, or whether the message was dropped due to no subscribers.
A warning is logged when messages are dropped.
Sourcepub fn subscribe(&self) -> Receiver<InterAgentMessage>
pub fn subscribe(&self) -> Receiver<InterAgentMessage>
Subscribe to all messages on the bus.
Warning: The raw broadcast receiver will silently drop messages if
the receiver lags behind. Consider using subscribe_lag_aware instead.
Sourcepub fn subscribe_lag_aware(&self) -> LagAwareReceiver
pub fn subscribe_lag_aware(&self) -> LagAwareReceiver
Subscribe with automatic lag handling.
Returns a LagAwareReceiver that logs a warning when messages are
skipped due to the receiver falling behind.
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Get the number of active subscribers.
Trait Implementations§
Source§impl Clone for MessageBus
impl Clone for MessageBus
Source§fn clone(&self) -> MessageBus
fn clone(&self) -> MessageBus
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for MessageBus
impl !UnwindSafe for MessageBus
impl Freeze for MessageBus
impl Send for MessageBus
impl Sync for MessageBus
impl Unpin for MessageBus
impl UnsafeUnpin for MessageBus
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