2 releases

Uses old Rust 2015

0.3.4 Jul 12, 2022
0.3.3 Jul 12, 2022

#1103 in Filesystem

Download history 24/week @ 2025-12-25 468/week @ 2026-01-01 933/week @ 2026-01-08 354/week @ 2026-01-15 1010/week @ 2026-01-22 949/week @ 2026-01-29 191/week @ 2026-02-05 1092/week @ 2026-02-12 1204/week @ 2026-02-19 1710/week @ 2026-02-26 731/week @ 2026-03-05 1929/week @ 2026-03-12 953/week @ 2026-03-19 1949/week @ 2026-03-26 707/week @ 2026-04-02 1004/week @ 2026-04-09

4,808 downloads per month
Used in 6 crates (3 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