#iterator #reader #read

iter-read

A Read implementation for iterators over u8 and related types

4 releases (2 breaking)

0.3.0 Jun 17, 2020
0.2.1 Sep 18, 2019
0.2.0 Oct 28, 2018
0.1.0 Apr 24, 2016

#90 in Rust patterns

Download history 651/week @ 2020-05-30 802/week @ 2020-06-06 746/week @ 2020-06-13 825/week @ 2020-06-20 524/week @ 2020-06-27 594/week @ 2020-07-04 729/week @ 2020-07-11 657/week @ 2020-07-18 532/week @ 2020-07-25 462/week @ 2020-08-01 380/week @ 2020-08-08 376/week @ 2020-08-15 537/week @ 2020-08-22 307/week @ 2020-08-29 182/week @ 2020-09-05 224/week @ 2020-09-12

2,128 downloads per month
Used in 9 crates (3 directly)

MIT/Apache

15KB
278 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.

The iterators must be fused (i.e. guarantee a None return from next() after they have returned None once); you need to call .fuse() on iterators that don't implement std::iter::FusedIterator.

Installation

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

[dependencies]
iter-read = "0.3"

Requirements

Minimum supported Rust version is 1.31.0. No other dependencies.

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");

No runtime deps

Features

  • unstable