pub struct Receiver<T> { /* private fields */ }
Expand description
The receiving half of the one-shot channel.
This half can only be owned and used by one thread.
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 and reset the channel.
If it succeeds it returns the value and resets the channel, returning a
new Sender
(which can send a value to this Receiver
).
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 the Sender
is
disconnected without sending a value. This is the same error as
RecvError::Disconnected
. RecvError::NoValue
will never be
returned, the Future
will return Poll::Pending
instead.
Sourcepub fn recv_once(self) -> RecvOnce<T> ⓘ
pub fn recv_once(self) -> RecvOnce<T> ⓘ
Returns an owned version of Receiver::recv
that can only be used
once.
See Receiver::recv
for more information.
Sourcepub fn try_reset(&mut self) -> Option<Sender<T>>
pub fn try_reset(&mut self) -> Option<Sender<T>>
Attempt to reset the channel.
If the sender is disconnected this will return a new Sender
. If the
sender is still connected this will return None
.
§Notes
If the channel contains a value it will be dropped.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns true
if the Sender
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.