Skip to main content

UnboundedReceiver

Struct UnboundedReceiver 

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

Receives values from the associated UnboundedSenders.

Created by unbounded_channel. Dropping it closes the channel and drops the values still queued.

Implementations§

Source§

impl<T> UnboundedReceiver<T>

Source

pub async fn recv(&mut self) -> Option<T>

Receives the next value, waiting for one if the channel is open and empty. Answers None once the channel is closed and drained (no sender, and no reserved slot still to be used).

Cancel safe: a dropped future loses no value.

Source

pub async fn recv_many(&mut self, buf: &mut Vec<T>, limit: usize) -> usize

Receives up to limit values into buf and answers how many, waiting for at least one. Answers 0 when limit is 0 or the channel ended.

Cancel safe: a dropped future loses no value.

Source

pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>>

Polls to receive the next value; the waker of cx is woken when a value arrives or the channel ends.

Source

pub fn poll_recv_many( &mut self, cx: &mut Context<'_>, buf: &mut Vec<T>, limit: usize, ) -> Poll<usize>

Polls to receive up to limit values into buf; see recv_many.

Source

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

Receives the next value without waiting.

§Errors

TryRecvError::Empty if a value may yet come, TryRecvError::Disconnected if the channel ended.

Source

pub fn close(&mut self)

Closes the receiving half without dropping it: no further value can be sent, and sends that wait fail. The values already buffered, and the slots reserved before the close, stay usable.

Source

pub fn is_closed(&self) -> bool

Whether the channel is closed: close was called, or every sender is gone. Buffered values may still be received.

Source

pub fn is_empty(&self) -> bool

Whether the channel holds no value.

Source

pub fn len(&self) -> usize

How many values the channel holds.

Trait Implementations§

Source§

impl<T> Debug for UnboundedReceiver<T>

Source§

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

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

impl<T> Drop for UnboundedReceiver<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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.