pub struct MessageBus { /* private fields */ }Expand description
An inter-agent message bus supporting publish/subscribe and history.
Implementations§
Source§impl MessageBus
impl MessageBus
pub fn new() -> Self
Sourcepub async fn send(&self, msg: AgentMessage)
pub async fn send(&self, msg: AgentMessage)
Send a message. Stores in history and notifies relevant subscribers.
Sourcepub async fn subscribe(&self, role: &str) -> Receiver<AgentMessage>
pub async fn subscribe(&self, role: &str) -> Receiver<AgentMessage>
Subscribe to messages for a given role. Returns a broadcast receiver.
Sourcepub async fn inbox(&self, role: &str) -> Vec<AgentMessage>
pub async fn inbox(&self, role: &str) -> Vec<AgentMessage>
Get all messages addressed to this role (including broadcasts).
Sourcepub async fn outbox(&self, role: &str) -> Vec<AgentMessage>
pub async fn outbox(&self, role: &str) -> Vec<AgentMessage>
Get all messages sent by this role.
Sourcepub async fn history(&self) -> Vec<AgentMessage>
pub async fn history(&self) -> Vec<AgentMessage>
Get the full message history.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more