Skip to main content

Mailbox

Struct Mailbox 

Source
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

Source

pub fn new() -> (Self, MailboxSender)

Creates a new mailbox, returning the mailbox and its sender.

Source

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.

Source

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.

Source

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.

Source

pub fn close(&mut self)

Closes the mailbox, preventing any further messages from being sent.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.