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

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

A better Sender struct. A sender can send values of type T and can signal an error of type E. (It can only signal one error).

Methods

impl<T, E> Sender<T, E> where T: Send, E: Send

fn send(&self, t: T) -> Result<(), T>

Sends a value through the channel asynchronously. If the value can not be sent (channel closed) the value is returned back in the Result.

fn send_all<I: Iterator<T>>(&self, i: I) -> Result<(), (T, I)>

Sends all the value in an iterator through the channel. If any of the sends fails, that value and the rest of the iterator are returned.

fn close(self)

Closes the channel. Shortcut for std::mem::drop(this).

fn error(self, e: E) -> Result<(), E>

Closes the channel with an error. This is by definition the last value that can be sent through the channe.;

fn is_closed(&self) -> bool

Returns true if it is known that the channel is closed. The channel might be closed, but if you haven't tried to write to it yet, then this method will return the wrong value.

Trait Implementations

impl<T, E> Clone for Sender<T, E> where T: Send, E: Send

fn clone(&self) -> Sender<T, E>

fn clone_from(&mut self, source: &Self)