Crates.io | shared-files |
lib.rs | shared-files |
version | 0.2.0 |
source | src |
created_at | 2023-06-12 22:51:10.45575 |
updated_at | 2024-05-20 16:46:19.065885 |
description | Single writer, multiple reader in-process file sharing |
homepage | |
repository | https://github.com/sunsided/shared-files-rs |
max_upload_size | |
id | 888533 |
size | 63,490 |
✨ Disk-Based Single-Writer, Multiple-Reader In-Process File Sharing ✨
Functionality for asynchronous single-writer, multiple-reader file operations where multiple concurrent readers need to read from a file that is currently being written by the same process. The intended use case is the parallel processing of byte streams with minimum (process) memory requirements, e.g. in web services moving around large files.
Normally, reading a file while it is written results in the read stream ending prematurely as EOF; the purpose of this crate is to prevent exactly that.
Any file type can be used as a backing as long as it implements the crate's SharedFileType
trait, which in turn
requires tokio::io::AsyncWrite
and tokio::io::AsyncRead
.
async-tempfile
: Enables the SharedTemporaryFile
type via
the async-tempfile
crate. Since this is how this crate was initially meant to be used, this feature is enabled by default.See tests/parallel_write_read.rs
for a usage example.
The example requires the async-tempfile
crate feature. To run it, use e.g.
cargo test --test parallel_write_read --features=async-tempfile