pub struct Mailbox { /* private fields */ }Expand description
Implementations§
Source§impl Mailbox
impl Mailbox
Sourcepub fn send_to(&self, to: &str, bytes: impl Into<Vec<u8>>) -> Result<()>
pub fn send_to(&self, to: &str, bytes: impl Into<Vec<u8>>) -> Result<()>
Send bytes to the agent named to.
Fails with TestkitError::UnknownAgent when no such agent exists, or
TestkitError::MailboxClosed when the recipient has already finished.
Sourcepub async fn recv(&mut self) -> Option<Envelope>
pub async fn recv(&mut self) -> Option<Envelope>
Wait for the next message from any sender, or None once every peer has
finished. Cached messages (set aside by recv_from)
come first, oldest to newest, before anything still on the channel.
Sourcepub fn try_recv(&mut self) -> Option<Envelope>
pub fn try_recv(&mut self) -> Option<Envelope>
Take a pending message from any sender without waiting.
Sourcepub async fn recv_from_any(&mut self, from: &[&str]) -> Option<Envelope>
pub async fn recv_from_any(&mut self, from: &[&str]) -> Option<Envelope>
Wait for the next message from any of the agents named in from, or
None once every peer has finished without one arriving.
Messages from senders outside the set that arrive first are cached in
order and remain available to later recv / recv_from*
calls, so selecting by sender does not drop anyone else’s messages.
Sourcepub fn try_recv_from_any(&mut self, from: &[&str]) -> Option<Envelope>
pub fn try_recv_from_any(&mut self, from: &[&str]) -> Option<Envelope>
Take a pending message from any of the agents named in from without
waiting. Non-matching messages already waiting are cached, not dropped.
Sourcepub async fn recv_from(&mut self, from: &str) -> Option<Envelope>
pub async fn recv_from(&mut self, from: &str) -> Option<Envelope>
Wait for the next message from the agent named from, or None once
every peer has finished without one arriving.
Sourcepub fn try_recv_from(&mut self, from: &str) -> Option<Envelope>
pub fn try_recv_from(&mut self, from: &str) -> Option<Envelope>
Take a pending message from the agent named from without waiting.