pub struct Receiver<T> { /* private fields */ }Expand description
Receiving side of the channel.
Implementations§
Source§impl<T> Receiver<T>
impl<T> Receiver<T>
Sourcepub fn try_recv(&mut self) -> Result<T, RecvError>
pub fn try_recv(&mut self) -> Result<T, RecvError>
Attempts to receive a value from this channel.
Sourcepub fn recv(&mut self) -> RecvValue<'_, T> ⓘ
pub fn recv(&mut self) -> RecvValue<'_, T> ⓘ
Returns a future that receives a value from the channel, waiting if the channel is empty.
If the returned Future returns None it means all Senders are
disconnected. This is the same error as RecvError::Disconnected.
RecvError::Empty will never be returned, the Future will return
Poll::Pending instead.
Sourcepub fn try_peek(&mut self) -> Result<&T, RecvError>
pub fn try_peek(&mut self) -> Result<&T, RecvError>
Attempts to peek a value from this channel.
Sourcepub fn peek(&mut self) -> PeekValue<'_, T> ⓘ
pub fn peek(&mut self) -> PeekValue<'_, T> ⓘ
Returns a future that peeks at a value from the channel, waiting if the channel is empty.
If the returned Future returns None it means all Senders are
disconnected. This is the same error as RecvError::Disconnected.
RecvError::Empty will never be returned, the Future will return
Poll::Pending instead.
Sourcepub fn new_sender(&self) -> Sender<T>
pub fn new_sender(&self) -> Sender<T>
Create a new Sender that sends to this channel.
§Safety
The same restrictions apply to this function as they do to
Sender::clone.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns false if all Senders are disconnected.
§Notes
Unlike Sender::is_connected this method doesn’t take the Manager
into account. This means that this method can return false and later
true (if the Manager created another Sender), which might be
unexpected.
Sourcepub fn has_manager(&self) -> bool
pub fn has_manager(&self) -> bool
Returns true if the Manager is connected.
Sourcepub fn register_waker(&mut self, waker: &Waker) -> bool
pub fn register_waker(&mut self, waker: &Waker) -> bool
Set the receiver’s waker to waker, if they are different. Returns
true if the waker is changed, false otherwise.
This is useful if you can’t call Receiver::recv but still want a
wake-up notification once messages are added to the inbox.