Struct pipe_channel::Receiver
[−]
[src]
pub struct Receiver<T> { /* fields omitted */ }
The receiving half of a channel.
Methods
impl<T> Receiver<T>
[src]
fn recv(&mut self) -> Result<T, RecvError>
[src]
Receive data sent by the corresponding Sender
.
This will block until a value is actually 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>
[src]
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> Drop for Receiver<T>
[src]
impl<T: Send> Send for Receiver<T>
[src]
impl<T> AsRawFd for Receiver<T>
[src]
impl<T> IntoRawFd for Receiver<T>
[src]
fn into_raw_fd(self) -> RawFd
[src]
Consumes this object, returning the raw underlying file descriptor. Read more
impl<T> FromRawFd for Receiver<T>
[src]
unsafe fn from_raw_fd(fd: RawFd) -> Self
[src]
Constructs a new instance of Self
from the given raw file descriptor. Read more
impl<T> Debug for Receiver<T>
[src]
impl<T> 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>
[src]
Creates an iterator from a value. Read more