[][src]Struct messages::mailbox::Mailbox

pub struct Mailbox<Input> { /* fields omitted */ }

Mailbox is an entity capable of receiving messages. It represents a receiver side of communication, and the sender side is represented using Address.

Implementations

impl<Input> Mailbox<Input>[src]

pub fn new() -> Self[src]

Creates a new Mailbox with a DEFAULT_CAPACITY.

pub fn with_capacity(capacity: usize) -> Self[src]

Creates a new Mailbox with a provided capacity.

pub fn address(&self) -> Address<Input>[src]

Creates an Address object to communicate with this Mailbox.

pub async fn receive<'_>(&'_ mut self) -> Result<Input, ReceiveError>[src]

Awaits for the any message to come and returns it. Returns an error if either this Mailbox has received a stop request, but was not resumed, or if all the senders have disconnected already.

pub async fn run_with<F, Fut>(
    __arg0: Self,
    __arg1: F
) -> Result<(), ReceiveError> where
    F: FnMut(Input) -> Fut,
    Fut: Future<Output = ()>, 
[src]

Runs an infinite loop which will handle all the incoming requests. Loop may exit with an Ok(()) value if this Mailbox will receive a stop request, or with an Err value if all the senders will disconnect without providing a stop request.

pub fn resume(&mut self)[src]

Enables a mailbox again after it received a stop request.

Trait Implementations

impl<Input: Debug> Debug for Mailbox<Input>[src]

impl<Input> Default for Mailbox<Input>[src]

Auto Trait Implementations

impl<Input> !RefUnwindSafe for Mailbox<Input>

impl<Input> Send for Mailbox<Input> where
    Input: Send

impl<Input> Sync for Mailbox<Input> where
    Input: Send

impl<Input> Unpin for Mailbox<Input>

impl<Input> !UnwindSafe for Mailbox<Input>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.