Struct std::comm::ReceiverUnstable [-]  [+] [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(&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.

Panics

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

If a panic 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(&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.

Panics

This function cannot panic.

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

Attempt to wait for a value on this receiver, but does not panic 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 panic 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 panic aspect.

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

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

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

Trait Implementations

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

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

fn drop(&mut self)