4 releases

0.3.3 Mar 20, 2019
0.3.2 Feb 7, 2019
0.3.1 Dec 6, 2018
0.3.0 Nov 1, 2018

#84 in Filesystem

Download history 16/week @ 2019-12-08 12/week @ 2019-12-15 22/week @ 2019-12-22 31/week @ 2019-12-29 6/week @ 2020-01-05 8/week @ 2020-01-12 16/week @ 2020-01-19 35/week @ 2020-01-26 11/week @ 2020-02-02 9/week @ 2020-02-09 10/week @ 2020-02-16 16/week @ 2020-02-23 14/week @ 2020-03-01 26/week @ 2020-03-08 9/week @ 2020-03-15 39/week @ 2020-03-22

53 downloads per month
Used in shakmaty-syzygy

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-preview

Preview release!

This is a preview release of positioned-io. Add it to your Cargo.toml like so:

[dependencies]
positioned-io-preview = "0.3"

All examples assume you are using it as:

extern crate positioned_io_preview as positioned_io;

License

positioned-io is licensed under the MIT license.

Dependencies