6 releases

Uses old Rust 2015

0.3.1 Nov 3, 2022
0.3.0 Aug 27, 2022
0.2.2 Jul 25, 2016
0.1.0 Jul 6, 2016

#106 in Filesystem

Download history 2331/week @ 2022-10-11 2497/week @ 2022-10-18 2407/week @ 2022-10-25 3002/week @ 2022-11-01 4037/week @ 2022-11-08 4777/week @ 2022-11-15 3735/week @ 2022-11-22 4144/week @ 2022-11-29 3521/week @ 2022-12-06 3274/week @ 2022-12-13 1207/week @ 2022-12-20 808/week @ 2022-12-27 2340/week @ 2023-01-03 2222/week @ 2023-01-10 2480/week @ 2023-01-17 1569/week @ 2023-01-24

8,762 downloads per month
Used in 39 crates (16 directly)

MIT license

490KB
1K SLoC

positioned-io

This crate allows you to specify an offset for reads and writes, without changing the current position in a file. This is similar to pread() and pwrite() in C.

The major advantages of this type of I/O are:

  • You don't need to seek before doing a random-access read or write, which is convenient.
  • Reads don't modify the file at all, so don't require mutability.

Build Status Windows build status Crates.io Documentation

Example

Read the fifth 512-byte sector of a file:

use std::fs::File;
use positioned_io::ReadAt;

// note that file does not need to be mut
let file = File::open("tests/pi.txt")?;

// read up to 512 bytes
let mut buf = [0; 512];
let bytes_read = file.read_at(2048, &mut buf)?;

Note: If possible use the RandomAccessFile wrapper. On Windows ReadAt directly on File is very slow.

Documentation

https://docs.rs/positioned-io

License

positioned-io is licensed under the MIT license.

Dependencies