pub struct Mailbox { /* private fields */ }Expand description
The receiving end of a process mailbox.
This is held by the process and used to receive messages.
Implementations§
Source§impl Mailbox
impl Mailbox
Sourcepub fn new() -> (Self, MailboxSender)
pub fn new() -> (Self, MailboxSender)
Creates a new mailbox, returning the mailbox and its sender.
Sourcepub async fn recv(&mut self) -> Option<Envelope>
pub async fn recv(&mut self) -> Option<Envelope>
Receives the next message, blocking until one is available.
Returns None if all senders have been dropped.
Sourcepub async fn recv_timeout(
&mut self,
duration: Duration,
) -> Result<Option<Envelope>, ()>
pub async fn recv_timeout( &mut self, duration: Duration, ) -> Result<Option<Envelope>, ()>
Receives the next message with a timeout.
Returns Ok(Some(envelope)) if a message was received,
Ok(None) if all senders were dropped,
or Err(()) if the timeout elapsed.
Sourcepub fn try_recv(&mut self) -> Result<Envelope, TryRecvError>
pub fn try_recv(&mut self) -> Result<Envelope, TryRecvError>
Tries to receive a message without blocking.
Returns Ok(envelope) if a message was available,
Err(TryRecvError::Empty) if no message was available,
or Err(TryRecvError::Disconnected) if all senders were dropped.
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