bufferedreader 1.0.0

A BufferedReader that behaves like the underlying File.read.
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 6.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.33 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Yuri6037/bufferedreader
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Yuri6037

BufferedReader

Description

This crate provides a BufferedReader that operates like the underlying File.read. That means:

  • If EOF then it returns the current number of bytes that could be read before EOF
  • If no EOF will be reached then the buffer shall be full

Example

Here is an example usage

use std::io::Result;

fn main() -> Result<()>
{
    let fle = File::open("./my_big_file")?;
    //The BufferedReader takes ownership so don't try to use the fle after this call
    let mut reader = BufferedReader::new(fle);
    let mut buf: [u8; 4] = [0; 4]; //Read 4 by 4 bytes
    let mut res = reader.read(&mut buf)?;

    while res > 0
    {
        println!("Read {} byte(s)", res);
        res = reader.read(&mut buf)?;
    }
    return Ok(());
}