Struct Receiver

Source
pub struct Receiver<T> { /* private fields */ }
Expand description

Receiving side of the channel.

Implementations§

Source§

impl<T> Receiver<T>

Source

pub fn try_recv(&mut self) -> Result<T, RecvError>

Attempts to receive a value from this channel.

Source

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.

Source

pub fn try_peek(&mut self) -> Result<&T, RecvError>

Attempts to peek a value from this channel.

Source

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.

Source

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.

Source

pub fn capacity(&self) -> usize

Returns the capacity of the channel.

Source

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.

Source

pub fn has_manager(&self) -> bool

Returns true if the Manager is connected.

Source

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.

Source

pub fn id(&self) -> Id

Returns the id of this receiver.

Trait Implementations§

Source§

impl<T: Debug> Debug for Receiver<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for Receiver<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Send> Send for Receiver<T>

Source§

impl<T> Sync for Receiver<T>

Source§

impl<T> Unpin for Receiver<T>

Auto Trait Implementations§

§

impl<T> Freeze for Receiver<T>

§

impl<T> !RefUnwindSafe for Receiver<T>

§

impl<T> !UnwindSafe for Receiver<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.