reader/reader.rs
1extern crate progress_streams;
2
3use progress_streams::ProgressReader;
4use std::fs::File;
5use std::io::Read;
6
7fn main() {
8 let mut total = 0;
9 let mut file = File::open("/dev/urandom").unwrap();
10 let mut reader = ProgressReader::new(&mut file, |progress: usize| {
11 total += progress;
12 println!("Read {} KiB", total / 1024);
13 });
14
15 let mut buffer = [0u8; 8192];
16 for _ in 0..10_000 {
17 reader.read(&mut buffer).unwrap();
18 }
19}