Receiver

Struct Receiver 

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

Reusable receiver of a multi-shot channel.

A Receiver can be used to receive a value using the Future returned by recv. It can also produce a one-shot Sender with the sender method, provided that there is currently no live sender.

A receiver can be created with the channel function or with the new method.

Implementations§

Source§

impl<T> Receiver<T>

Source

pub fn new() -> Self

Creates a new receiver.

Source

pub fn sender(&mut self) -> Option<Sender<T>>

Returns a new sender if there is currently no live sender.

This operation is wait-free. It is guaranteed to succeed (i) on its first invocation and (ii) on further invocations if the future returned by recv has been awaited (i.e. polled to completion) after the previous sender was created.

Source

pub fn recv(&mut self) -> Recv<'_, T>

Receives a message asynchronously.

If the channel is empty, the future returned by this method waits until there is a message. If there is no live sender and no message, the future completes and returns an error.

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> Default for Receiver<T>

Source§

fn default() -> Self

Returns the “default value” for a type. 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> RefUnwindSafe for Receiver<T>

Source§

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

Source§

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

Source§

impl<T> UnwindSafe for Receiver<T>

Auto Trait Implementations§

§

impl<T> Freeze for Receiver<T>

§

impl<T> Unpin for Receiver<T>
where T: Unpin,

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.