#byte-reader #limit #numbers #read

limit-reader

A simple reader that limits the number of bytes read from an underlying reader

4 releases

0.1.4 Jun 28, 2024
0.1.3 Jun 25, 2024
0.1.1 Jun 5, 2024
0.1.0 Jun 5, 2024

#5 in #byte-reader

MIT license

4KB
51 lines

Limit Reader

A simple reader that limits the number of bytes read from an underlying reader.

Install

cargo add limit-reader

Usage

fn foo() {
    let hello_txt = fs::File::open("file").unwrap();
    let mut reader = LimiterReader::new(hello_txt, 1024 * 1024);
    let mut r1 = vec![0u8];
    reader.read_to_end(&mut r1).unwrap();
}

No runtime deps