Crate read_byte_slice [] [src]

ByteSliceIter reads bytes from a reader and allows iterating over them as slices with a maximum length, similar to the chunks method on slices.

It is implemented as a FallibleStreamingIterator so that it can reuse its buffer and not allocate for each chunk. (That trait is re-exported here for convenience.)


use read_byte_slice::{ByteSliceIter, FallibleStreamingIterator};
use std::fs::File;
let f = File::open("src/")?;
// Iterate over the file's contents in 8-byte chunks.
let mut iter = ByteSliceIter::new(f, 8);
while let Some(chunk) = {
    println!("{:?}", chunk);



An iterator over byte slices from a Read that reuses the same buffer instead of allocating.



A fallible, streaming iterator.