pub struct Mailbox { /* private fields */ }Expand description
Mailbox provides named channels for agent-to-agent messaging.
Each agent registers by name and gets a receiver. Messages are routed
by the to field on the Message.
Implementations§
Source§impl Mailbox
impl Mailbox
pub fn new(buffer_size: usize) -> Self
Sourcepub async fn register(&self, name: &str) -> Receiver<Message>
pub async fn register(&self, name: &str) -> Receiver<Message>
Register an agent and return its message receiver.
Sourcepub async fn send(&self, msg: Message) -> Result<(), MultiError>
pub async fn send(&self, msg: Message) -> Result<(), MultiError>
Send a message to a named agent.
Sourcepub async fn broadcast(&self, msg: Message) -> Result<(), MultiError>
pub async fn broadcast(&self, msg: Message) -> Result<(), MultiError>
Broadcast a message to all registered agents.
Sourcepub async fn unregister(&self, name: &str)
pub async fn unregister(&self, name: &str)
Unregister an agent (drops its sender).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Mailbox
impl !RefUnwindSafe for Mailbox
impl Send for Mailbox
impl Sync for Mailbox
impl Unpin for Mailbox
impl UnsafeUnpin for Mailbox
impl !UnwindSafe for Mailbox
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> 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