read_iter

Crates.ioread_iter
lib.rsread_iter
version0.1.2
sourcesrc
created_at2020-12-06 19:54:23.607617
updated_at2020-12-06 22:34:37.825415
descriptionTo any std::io::Read implementor, add also Iterator<Item=u8> implementation
homepage
repositoryhttps://github.com/jeremiah-shaulov/read_iter
max_upload_size
id320214
size7,117
Jeremiah Shaulov (jeremiah-shaulov)

documentation

README

read_iter

Documentation crates.io

To any std::io::Read implementor, add also Iterator<Item=u8> implementation.

Installation

In Cargo.toml of your project add:

[dependencies]
read_iter = "0.1"

Examples

use std::fs::File;
use read_iter::ReadIter;

let file = File::open("/tmp/test.txt").unwrap();
// "file" implements std::io::Read
let mut it = ReadIter::new(file);
// now "it" also implements std::io::Read
// and "&mut it" implements Iterator<Item=u8>
// also "it" has internal buffer, and implements std::io::BufRead
for byte in &mut it
{	// ...
}
// in case of i/o error, the iteration ends, and take_last_error() will return Err
it.take_last_error().unwrap();
Commit count: 4

cargo fmt