#iterator #reader #read

iter-read

A Read implementation for iterators over u8 and related types

3 unstable releases

✓ Uses Rust 2018 edition

0.2.1 Sep 18, 2019
0.2.0 Oct 28, 2018
0.1.0 Apr 24, 2016

#113 in Rust patterns

Download history 104/week @ 2019-10-11 171/week @ 2019-10-18 152/week @ 2019-10-25 134/week @ 2019-11-01 122/week @ 2019-11-08 136/week @ 2019-11-15 128/week @ 2019-11-22 91/week @ 2019-11-29 109/week @ 2019-12-06 115/week @ 2019-12-13 31/week @ 2019-12-20 33/week @ 2019-12-27 99/week @ 2020-01-03 180/week @ 2020-01-10 93/week @ 2020-01-17

559 downloads per month
Used in 4 crates (2 directly)

MIT/Apache

15KB
280 lines

iter-read

Build status Latest Version

Documentation

This crate is a small library that provides a type that implements std::io::Read for iterators over bytes (u8) and sequences of it, and also Result<u8, E>, Result<Vec<u8>, E> etc.

Installation

This crate works with Cargo and can be found on crates.io with a Cargo.toml like:

[dependencies]
iter-read = "*"

Usage

A simple example:

use std::io::Read;
use iter_read::IterRead;
let source = vec![1, 2, 7, 42, 123];
let mut reader = IterRead::new(source.iter());
let mut buf = vec![0; 3];
reader.read_exact(&mut buf).unwrap();
assert_eq!(buf, b"\x01\x02\x07");

lib.rs:

A small crate that provides an adapter to Read from an iterator over bytes. This is useful if you want to use an API that takes a Read instance, but want to feed it data from an iterator.

Example:

use std::io::Read;
use iter_read::IterRead;

let source = vec![1, 2, 7, 42, 123];
let mut reader = IterRead::new(source.iter());
let mut buf = vec![0; 3];
reader.read_exact(&mut buf).unwrap();
assert_eq!(buf, b"\x01\x02\x07");

No runtime deps