#io #reader


A Bufreader ensures N bytes in buffer

2 unstable releases

✓ Uses Rust 2018 edition

0.2.0 Oct 4, 2019
0.1.0 Sep 29, 2019

#620 in Data structures

Download history 23/week @ 2020-02-16 29/week @ 2020-02-23 21/week @ 2020-03-01 25/week @ 2020-03-08 17/week @ 2020-03-15 31/week @ 2020-03-22 7/week @ 2020-04-05 8/week @ 2020-04-12 1/week @ 2020-04-26 2/week @ 2020-05-10 2/week @ 2020-05-24 6/week @ 2020-05-31

72 downloads per month


196 lines


ensured_bufreader at crates.io ensured_bufreader at docs.rs Build Status (master) Build Status (dev)


ensured_bufreader provides EnsuredBufReader that ensured length bytes in its buffer if it can read from underlying reader.

std::io::BufReader doesn't read bytes from underlying reader if it has buffered bytes. This behavior is better if you need buffering for performance. But, if you need buffering for algorithm such as peeking N bytes, BufReader donesn't ensure N bytes in its buffer.

If there are too few bytes in buffer when .fill_buf() called, EnsuredBufReader tries to read additional bytes from underlying reader and keep .fill_buf()?.len() > ensured.

Comparition with other crates

buffered-reader provides same functionality as this crate. But there is some differences.

ensured_bufreader buffered-reader = "0.10.0"
Implementation strategy Uses standard trait BufRead and simple wrapper struct Provides new trait and some implementaions
When returns error Immediately Saved and returned when read position error occuered
License MIT or Apache-2.0 (permissive) GPL-3.0 (copyleft)


ensured_bufreader is distributed under the terms of both the MIT license and the Apache License (Version 2.0).


No runtime deps