10 releases

0.3.5 Oct 3, 2025
0.3.4 Apr 6, 2025
0.3.3 Nov 1, 2023
0.3.2 Aug 19, 2023
0.1.0 Jul 6, 2016

#53 in Filesystem

Download history 62143/week @ 2025-12-12 42117/week @ 2025-12-19 29706/week @ 2025-12-26 58654/week @ 2026-01-02 67069/week @ 2026-01-09 100290/week @ 2026-01-16 129517/week @ 2026-01-23 185947/week @ 2026-01-30 231775/week @ 2026-02-06 189571/week @ 2026-02-13 73477/week @ 2026-02-20 68298/week @ 2026-02-27 74763/week @ 2026-03-06 66696/week @ 2026-03-13 77018/week @ 2026-03-20 77103/week @ 2026-03-27

307,378 downloads per month
Used in 153 crates (28 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.

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