19 releases (12 breaking)

0.14.1 Jan 11, 2024
0.13.0 Jun 30, 2023
0.12.2 Mar 29, 2023
0.12.0 Nov 27, 2022
0.3.0 Mar 5, 2021

#806 in Rust patterns

Download history 24/week @ 2024-01-11 59/week @ 2024-02-22 29/week @ 2024-02-29 5/week @ 2024-03-07 5/week @ 2024-03-14

98 downloads per month
Used in nameless

Apache-2.0…

86KB
2K SLoC

io-arrays

Random-access I/O

Github Actions CI Status crates.io page docs.rs docs

Think of an I/O array as a Vec<u8> which lives outside the program. You can index into it and copy data in and out. You can append to it or shrink it from the back.

In I/O terms, an I/O array is an abstraction of a "file". It supports doing I/O at arbitrary offsets, appending, and truncating. You can read from it in a streaming fashion using ReadAt::read_via_stream_at.

TODO: Writing to an array in a streaming fashion is not yet supported.

This crate defines ReadAt, WriteAt, and EditAt traits which define interfaces to random-access or seekable devices, such as normal files, block devices, disk partitions, and memory buffers.

It also defines ArrayReader, ArrayWriter, and ArrayEditor types which implement the above traits and and can be constructed from any file-like type. On Posix-ish platforms, with support for WASI in development, these types just contain a single file descriptor (and implement AsRawFd), plus any resources needed to safely hold the file descriptor live. On Windows, they contain a single file handle (and implement AsRawHandle).

Support for async-std is temporarily disabled until those crates contain the needed implementations of the I/O safety traits.

Dependencies

~3–13MB
~149K SLoC