Receiver

Struct Receiver 

Source
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>

Source

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).

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 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.

Source

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.

Source

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.

Source

pub fn is_connected(&self) -> bool

Returns true if the Sender 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.

Trait Implementations§

Source§

impl<T> 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: Send> Sync for Receiver<T>

Auto Trait Implementations§

§

impl<T> Freeze for Receiver<T>

§

impl<T> !RefUnwindSafe for Receiver<T>

§

impl<T> Unpin 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.