Struct pipe_channel::Receiver [] [src]

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

The receiving half of a channel.

Methods

impl<T: Send> Receiver<T>
[src]

fn recv(&mut self) -> Result<T, RecvError>

Receive data sent by the corresponding Sender.

This will block until a value is actully sent, if none is already.

Errors

If the corresponding Sender is already dropped (or gets dropped during the wait), this method will return Err(RecvError).

Examples

Success:

use std::thread;
use pipe_channel::*;

let (mut tx, mut rx) = channel();
let handle = thread::spawn(move || {
    tx.send(35).unwrap();
    tx.send(42).unwrap();
});
assert_eq!(rx.recv().unwrap(), 35);
assert_eq!(rx.recv().unwrap(), 42);
handle.join().unwrap();

Failure:

use pipe_channel::*;
use std::sync::mpsc::RecvError;
use std::mem::drop;

let (tx, mut rx) = channel::<i32>();
drop(tx);
assert_eq!(rx.recv(), Err(RecvError));

fn iter(&mut self) -> Iter<T>

Get an iterator over data sent through the channel.

Examples

use pipe_channel::*;
use std::mem::drop;

let (mut tx, mut rx) = channel();
for i in 0..1024 {
    tx.send(i).unwrap();
}
drop(tx);

for (i, j) in rx.iter().take(10).zip(0..10) {
    assert_eq!(i, j);
}
let v1: Vec<_> = rx.into_iter().collect();
let v2: Vec<_> = (10..1024).collect();
assert_eq!(v1, v2);

Trait Implementations

impl<T: Debug + Send> Debug for Receiver<T>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<T: Send> Send for Receiver<T>
[src]

impl<T: Send> Drop for Receiver<T>
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more

impl<T: Send> AsRawFd for Receiver<T>
[src]

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more

impl<T: Send> IntoIterator for Receiver<T>
[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

fn into_iter(self) -> IntoIter<T>

Creates an iterator from a value. Read more

impl<'a, T: 'a + Send> IntoIterator for &'a mut Receiver<T>
[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more