Crates.io | bufferedreader |
lib.rs | bufferedreader |
version | 1.0.0 |
source | src |
created_at | 2021-01-18 19:17:05.03494 |
updated_at | 2021-01-18 19:17:05.03494 |
description | A BufferedReader that behaves like the underlying File.read. |
homepage | |
repository | https://gitlab.com/Yuri6037/BufferedReader |
max_upload_size | |
id | 343634 |
size | 6,797 |
This crate provides a BufferedReader that operates like the underlying File.read. That means:
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(());
}