Struct std::comm::Receiver[src]

pub struct Receiver<T> {
    // some fields omitted
}

The receiving-half of Rust's channel type. This half can only be owned by one task

Methods

impl<T: Send> Receiver<T>

fn recv<T: Send>(&self) -> T

Blocks waiting for a value on this receiver

This function will block if necessary to wait for a corresponding send on the channel from its paired Sender structure. This receiver will be woken up when data is ready, and the data will be returned.

Failure

Similar to channels, this method will trigger a task failure if the other end of the channel has hung up (been deallocated). The purpose of this is to propagate failure among tasks.

If failure is not desired, then there are two options:

  • If blocking is still desired, the recv_opt method will return None when the other end hangs up

  • If blocking is not desired, then the try_recv method will attempt to peek at a value on this receiver.

fn try_recv<T: Send>(&self) -> Result<T, TryRecvError>

Attempts to return a pending value on this receiver without blocking

This method will never block the caller in order to wait for data to become available. Instead, this will always return immediately with a possible option of pending data on the channel.

This is useful for a flavor of "optimistic check" before deciding to block on a receiver.

This function cannot fail.

fn recv_opt<T: Send>(&self) -> Result<T, ()>

Attempt to wait for a value on this receiver, but does not fail if the corresponding channel has hung up.

This implementation of iterators for ports will always block if there is not data available on the receiver, but it will not fail in the case that the channel has been deallocated.

In other words, this function has the same semantics as the recv method except for the failure aspect.

If the channel has hung up, then Err is returned. Otherwise Ok of the value found on the receiver is returned.

fn iter<T: Send>(&'a self) -> Messages<'a, T>

Returns an iterator which will block waiting for messages, but never fail!. It will return None when the channel has hung up.

Trait Implementations

impl<T> UnsafeFlavor<T> for Receiver<T>

fn inner_unsafe<T>(&'a self) -> &'a Unsafe<Flavor<T>>

unsafe fn mut_inner<T>(&'a self) -> &'a mut Flavor<T>

unsafe fn inner<T>(&'a self) -> &'a Flavor<T>

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

fn can_recv<T: Send>(&self) -> bool

fn start_selection<T: Send>(&self, task: BlockedTask) -> Result<(), BlockedTask>

fn abort_selection<T: Send>(&self) -> bool

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

fn drop<T: Send>(&mut self)