Struct dribble::DribbleReader [-] [+] [src]

pub struct DribbleReader<R: Read> {
    // some fields omitted
}

Wrap an implementation of Read, and return bytes in small, random-sized chunks when read is called.

use std::io::{Cursor, Read};
use dribble::DribbleReader;

let input = b"This is my test data";
let mut cursor = Cursor::new(input as &[u8]);
let mut dribble = DribbleReader::new(&mut cursor);
let mut output = vec!();
dribble.read_to_end(&mut output).unwrap();
assert_eq!(input as &[u8], &output as &[u8]);

Methods

impl<R: Read> DribbleReader<R>

fn new(source: R) -> Self

Create a new DribbleReader. The read function will only return 0 if source.read returns 0.

Trait Implementations

impl<R: Read> Read for DribbleReader<R>

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

fn by_ref(&mut self) -> &mut Self

fn bytes(self) -> Bytes<Self>

fn chars(self) -> Chars<Self>

fn chain<R>(self, next: R) -> Chain<Self, R> where R: Read

fn take(self, limit: u64) -> Take<Self>

fn tee<W>(self, out: W) -> Tee<Self, W> where W: Write