Struct bchannel::Receiver [] [src]

pub struct Receiver<T: Send, E: Send> {
    // some fields omitted
}

The receiving end of the channel.

Methods

impl<T, E> Receiver<T, E> where T: Send + 'static, E: Send + 'static

fn from_old(v: Receiver<CommMsg<T, E>>) -> Receiver<T, E>

Converts an old-style receiver to a bchannel receiver.

fn into_inner(self) -> (Receiver<CommMsg<T, E>>, Option<E>)

Returns the old-style receiver along with the error. The error will be None unless this channel was closed by an error.

fn recv(&self) -> Option<T>

Returns the next message asyncrhonously.

  • If there is a message in the channels queue, it is returned in Some.
  • If there is no message ready, None is returned.
  • If the channel is closed, None is returned.
  • If the channel is closed with an error, None is returned.

fn recv_block(&self) -> Option<T>

Returns the next message in the channe. This method will block until either a message arrives or the channel is closed (either regularly) or by an error.

  • If a message arrives, the message is returned inside of Some.
  • If the channel is closed, None is returned.
  • If the channel is closed with an error, None is returned.

fn has_error(&self) -> bool

Returns true if the channel was closed with an error.

fn take_error(&self) -> Option<E>

Returns the error if the channel was closed with an error. This method moves the error out of the Receiver, so subsequent calls will return None.

Returns None if the channel wasn't closed with an error, or if the error has already been taken.

fn is_closed(&self) -> bool

Returns true if the channel is closed.

fn iter(&self) -> ReceiverIterator<T, E>

Returns an iterator over the messages in this receiver. The iterator is non-blocking, and borrows this receiver.

fn blocking_iter(&self) -> ReceiverIterator<T, E>

Returns an iterator over the messages in this receiver. The iterator is blocking and borrows this receiver.

fn into_iter(self) -> ReceiverIterator<'static, T, E>

Returns an iterator over the messages in this receiver. The iterator is non-blocking and consumes this receiver.

fn into_blocking_iter(self) -> ReceiverIterator<'static, T, E>

Returns an iterator over the messages in this receiver. The iterator is blocking, and consumes this receiver.

Trait Implementations

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