Crates.io | positioned-io |
lib.rs | positioned-io |
version | 0.3.3 |
source | src |
created_at | 2016-07-06 16:46:58.325227 |
updated_at | 2023-11-01 19:19:14.596885 |
description | Reading and writing at an offset |
homepage | |
repository | https://github.com/vasi/positioned-io |
max_upload_size | |
id | 5597 |
size | 1,068,543 |
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:
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.
positioned-io is licensed under the MIT license.