buffered_offset_reader

Crates.iobuffered_offset_reader
lib.rsbuffered_offset_reader
version0.6.0
sourcesrc
created_at2019-02-05 06:52:15.766523
updated_at2019-02-14 04:44:24.613208
descriptionBuffered file read_at (pread)
homepage
repositoryhttps://github.com/sbillig/buffered_offset_reader
max_upload_size
id112861
size26,986
all (github:sunrise-choir:all)

documentation

https://docs.rs/buffered_offset_reader/

README

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(())
}
Commit count: 22

cargo fmt