Struct heph_inbox::Receiver
source · [−]pub struct Receiver<T> { /* private fields */ }
Expand description
Receiving side of the channel.
Implementations
sourceimpl<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>ⓘNotable traits for RecvValue<'r, T>impl<'r, T> Future for RecvValue<'r, T> type Output = Option<T>;
pub fn recv(&mut self) -> RecvValue<'_, T>ⓘNotable traits for RecvValue<'r, T>impl<'r, T> Future for RecvValue<'r, T> type Output = Option<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 Sender
s 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>ⓘNotable traits for PeekValue<'r, T>impl<'r, T> Future for PeekValue<'r, T> type Output = Option<&'r T>;
pub fn peek(&mut self) -> PeekValue<'_, T>ⓘNotable traits for PeekValue<'r, T>impl<'r, T> Future for PeekValue<'r, T> type Output = Option<&'r 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 Sender
s 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 Sender
s 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.
Trait Implementations
impl<T: Send> Send for Receiver<T>
impl<T> Sync for Receiver<T>
impl<T> Unpin for Receiver<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for Receiver<T>
impl<T> !UnwindSafe for Receiver<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more