Crates.io | async-spooled-tempfile |
lib.rs | async-spooled-tempfile |
version | 0.1.0 |
source | src |
created_at | 2024-12-11 21:43:02.560599 |
updated_at | 2024-12-11 21:43:02.560599 |
description | Asynchronous spooled temporary file |
homepage | |
repository | https://github.com/AverageADF/async-spooled-tempfile |
max_upload_size | |
id | 1480556 |
size | 31,903 |
Crate exposing an asynchronous version of the tempfile::SpooledTempFile
structure provided by the tempfile crate.
Add the following line to your Cargo.toml
file:
[dependencies]
async-spooled-tempfile = "0.1.0"
use async_spooled_tempfile::{SpooledData, SpooledTempFile};
use tokio::io::AsyncWriteExt;
#[tokio::main]
async fn main() {
let mut sf = SpooledTempFile::new(10);
sf.write_all(b"12345").await.unwrap();
assert!(!sf.is_rolled());
sf.write_all(b"6789abc").await.unwrap();
assert!(sf.is_rolled());
assert!(std::matches!(
sf.into_inner().await,
Ok(SpooledData::OnDisk(_file))
));
}