[−][src]Struct messages::mailbox::Mailbox
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]
__arg0: Self,
__arg1: F
) -> Result<(), ReceiveError> where
F: FnMut(Input) -> Fut,
Fut: Future<Output = ()>,
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
Auto Trait Implementations
impl<Input> !RefUnwindSafe for Mailbox<Input>
impl<Input> Send for Mailbox<Input> where
Input: Send,
Input: Send,
impl<Input> Sync for Mailbox<Input> where
Input: Send,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,