pub struct MailboxReceiver { /* private fields */ }Expand description
The receiver half of a mailbox. Unique — only one consumer.
Implementations§
Source§impl MailboxReceiver
impl MailboxReceiver
Sourcepub fn try_recv(&mut self) -> Option<Arc<Message>>
pub fn try_recv(&mut self) -> Option<Arc<Message>>
Tries to receive a single message without blocking.
Returns Some(msg) if available, None if the queue is empty.
Sourcepub async fn recv(&mut self) -> Option<Arc<Message>>
pub async fn recv(&mut self) -> Option<Arc<Message>>
Receives a single message, awaiting if the queue is empty.
Returns Some(msg) if received, None if the mailbox was closed.
Convenience method for tests and non-batch consumers.
Sourcepub fn try_recv_batch(
&mut self,
buf: &mut Vec<Arc<Message>>,
max: usize,
) -> usize
pub fn try_recv_batch( &mut self, buf: &mut Vec<Arc<Message>>, max: usize, ) -> usize
Drains up to max messages into buf without blocking.
Returns the number of messages drained. Zero if empty.
The messages are appended to buf in FIFO order.
Sourcepub async fn recv_batch(
&mut self,
buf: &mut Vec<Arc<Message>>,
max: usize,
) -> usize
pub async fn recv_batch( &mut self, buf: &mut Vec<Arc<Message>>, max: usize, ) -> usize
Receives a batch of messages, awaiting if the queue is empty.
First tries a non-blocking drain. If empty, waits for Notify
(cancel-safe), then drains again. Returns the number of messages
received (0 means the mailbox was closed).
§Cancel Safety
This method is cancel-safe. The Notify::notified() future can be
dropped at any time without losing notifications.