#buffered #pread #read_at #seek_read

buffered_offset_reader

Buffered file read_at (pread)

7 releases (breaking)

✓ Uses Rust 2018 edition

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 23/week @ 2019-10-14 10/week @ 2019-10-21 15/week @ 2019-10-28 11/week @ 2019-11-04 5/week @ 2019-11-11 23/week @ 2019-11-18 96/week @ 2019-11-25 14/week @ 2019-12-02 70/week @ 2019-12-09 1/week @ 2019-12-16 9/week @ 2019-12-23 6/week @ 2020-01-06 32/week @ 2020-01-13

99 downloads per month
Used in 1 crate

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