2 releases

Uses old Rust 2015

0.3.4 Jul 12, 2022
0.3.3 Jul 12, 2022

#1050 in Filesystem

Download history 669/week @ 2025-08-15 711/week @ 2025-08-22 1137/week @ 2025-08-29 285/week @ 2025-09-05 74/week @ 2025-09-12 301/week @ 2025-09-19 274/week @ 2025-09-26 253/week @ 2025-10-03 411/week @ 2025-10-10 788/week @ 2025-10-17 510/week @ 2025-10-24 851/week @ 2025-10-31 797/week @ 2025-11-07 718/week @ 2025-11-14 533/week @ 2025-11-21 602/week @ 2025-11-28

2,918 downloads per month
Used in 5 crates (2 directly)

MIT license

490KB
1K SLoC

positioned-io2

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.

Crates.io Documentation

Fork

This is a fork of positioned-io, which seem to have become unmaintained.

Example

Read the fifth 512-byte sector of a file:

use std::fs::File;
use positioned_io2::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.

License

positioned-io2 is licensed under the MIT license.

Dependencies