Struct sync_channel::Receiver

source ·
pub struct Receiver<T: Send, P: DeadlockPrevention = Spin> { /* private fields */ }
Expand description

The receiver side of a channel.

Implementations§

source§

impl<T: Send, P: DeadlockPrevention> Receiver<T, P>

source

pub fn receive(&self) -> Result<T, Error>

Receive a message, blocking until a message is available in the buffer.

Returns the message if it was received properly, otherwise returns an Error.

source

pub fn receive_buf(&self, buf: &mut [T]) -> Result<usize, Error>

Receives objects placing them in a buffer and returning the number of objects received.

This method only blocks on the first object being received.

source

pub fn try_receive(&self) -> Result<T, Error>

Tries to receive a message, only succeeding if a message is already available in the buffer.

If receive succeeds returns Some(Ok(T)). If an endpoint is disconnected returns Some(Err(ChannelStatus::Disconnected)). If no such message exists, it returns None without blocking

source

pub fn try_receive_buf(&self, buf: &mut [T]) -> Result<usize, Error>

Receives objects placing them in a buffer and returning the number of objects received.

This method does not block.

source

pub fn is_disconnected(&self) -> bool

Returns true if the channel is disconnected.

source

pub fn sender(&self) -> Sender<T, P>

Obtain a Sender endpoint connected to the same channel as this Receiver.

Trait Implementations§

source§

impl<T: Send, P: DeadlockPrevention> Clone for Receiver<T, P>

source§

fn clone(&self) -> Self

Clones this Receiver, returning another Receiver connected to the same channel.

This increments the channel’s receiver count. If there were previously no receivers, the channel status is updated to Connected.

1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Send, P: DeadlockPrevention> Drop for Receiver<T, P>

When the only remaining Receiver is dropped, we mark the channel as disconnected and notify all of the Senders

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, P = Spin> !RefUnwindSafe for Receiver<T, P>

§

impl<T, P> Send for Receiver<T, P>where T: Sync,

§

impl<T, P> Sync for Receiver<T, P>where T: Sync,

§

impl<T, P> Unpin for Receiver<T, P>

§

impl<T, P = Spin> !UnwindSafe for Receiver<T, P>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.