4 releases

0.2.2 Jul 25, 2016
0.2.1 Jul 12, 2016
0.2.0 Jul 12, 2016
0.1.0 Jul 6, 2016

#173 in Filesystem

Download history 299/week @ 2019-12-02 291/week @ 2019-12-09 235/week @ 2019-12-16 90/week @ 2019-12-23 80/week @ 2019-12-30 264/week @ 2020-01-06 248/week @ 2020-01-13 169/week @ 2020-01-20 176/week @ 2020-01-27 236/week @ 2020-02-03 290/week @ 2020-02-10 420/week @ 2020-02-17 496/week @ 2020-02-24 264/week @ 2020-03-02 301/week @ 2020-03-09 558/week @ 2020-03-16

743 downloads per month
Used in 5 crates

MIT license

60KB
1K SLoC

Razor 1K SLoC // 0.3% comments Intel HEX 40 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 Crates.io

Example

Read the fifth 512-byte sector of a file:

use positioned_io::ReadAt;

// Note that file does not need to be mut!
let file = try!(File::open("foo.data"));
let mut buf = vec![0; 512];
let bytes_read = try!(file.read_at(2048, &mut buf));

Documentation

http://vasi.github.io/positioned-io/positioned_io/

Usage

This crate works with Cargo and is on crates.io. Add it to your Cargo.toml like so:

[dependencies]
positioned-io = "0.2.0"

Dependencies

~185KB