#buffered #pread #read_at #seek_read

buffered_offset_reader

Buffered file read_at (pread)

7 releases (breaking)

0.6.0 Feb 14, 2019
0.5.0 Feb 14, 2019
0.4.0 Feb 13, 2019
0.3.0 Feb 7, 2019
0.1.1 Feb 5, 2019

#4 in #pread

Download history 1/week @ 2020-04-01 31/week @ 2020-04-08 27/week @ 2020-04-15 3/week @ 2020-04-22 2/week @ 2020-04-29 4/week @ 2020-05-06 10/week @ 2020-05-20 17/week @ 2020-05-27 15/week @ 2020-06-03 3/week @ 2020-06-10 2/week @ 2020-06-24 8/week @ 2020-07-01 9/week @ 2020-07-08 17/week @ 2020-07-15

66 downloads per month
Used in 2 crates (via flumedb)

MIT/Apache

13KB
263 lines

buffered_offset_reader

Build Status Documentation

Rust crate for buffered reading of a file at arbitrary offsets.

Uses std::os::unix::fs::FileExt::read_at() on unix (aka pread()) or std::os::windows::fs::FileExt::seek_read() on windows to do thread-safe reads of the underlying file.

Examples

use buffered_offset_reader::{BufOffsetReader, OffsetReadMut};
use std::fs::File;

fn main() -> std::io::Result<()> {
    let f = File::open("log.txt")?;
    let mut reader = BufOffsetReader::new(f);
    let mut tmp = vec![0; 8];

    reader.read_at(&mut tmp, 0)?;  // read 8 bytes at offset 0

	// This read will be fulfilled by the reader's internal buffer,
	// so it won't require a system call.
    reader.read_at(&mut tmp, 32)?; // read 8 bytes at offset 32

    Ok(())
}

No runtime deps