Struct bchannel::Receiver [-]  [+] [src]

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

A better Receiver struct. A receiver can receive values of type T and can contain at most one error of type E.

Methods

impl<T, E> Receiver<T, E> where T: Send, E: Send + Sync

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

If there is a value in the channel, this function returns the first value in the channel.

This method is asynchronous and will never fail.

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

This method blocks until a value is in the channel and then it returns that value. If the channel is closed, None is returned.

fn has_error(&self) -> bool

Returns true if this channel has been closed due to an error.

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

Returns the error if one exists. This moves the value out of the receiver.

fn is_closed(&self) -> bool

Returns true if this channel has been closed for any reason: * Closed naturally * Closed due to an error

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

Returns an iterator that will run through all values cached in the receiver. The returned iterator will never block.

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

Returns an iterator that will run through all values in the channel until the channel closes or an error is sent. This function blocks when it runs out of cached values.

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

Wraps the receiver into an iterator that will run until the cached values are exhausted or the channel closes.

This iterator will never block.

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

Wraps the receiver into an iterator that will run until the channel closes.

This iterator blocks when it runs out of cached values.