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>
impl<T: Send, P: DeadlockPrevention> Receiver<T, P>
sourcepub fn receive(&self) -> Result<T, Error>
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.
sourcepub fn receive_buf(&self, buf: &mut [T]) -> Result<usize, Error>
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.
sourcepub fn try_receive(&self) -> Result<T, Error>
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
sourcepub fn try_receive_buf(&self, buf: &mut [T]) -> Result<usize, Error>
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.
sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if the channel is disconnected.
Trait Implementations§
source§impl<T: Send, P: DeadlockPrevention> Clone for Receiver<T, P>
impl<T: Send, P: DeadlockPrevention> Clone for Receiver<T, P>
source§fn clone(&self) -> Self
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)
fn clone_from(&mut self, source: &Self)
source. Read more