Skip to content

Asynchronous spooled temporary file for Rust projects

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

AverageADF/async-spooled-tempfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-spooled-tempfile


Crate exposing an asynchronous version of the tempfile::SpooledTempFile structure provided by the tempfile crate.

Dependency

Add the following line to your Cargo.toml file:

[dependencies]
async-spooled-tempfile = "0.1.0"

Example

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))
    ));
}

About

Asynchronous spooled temporary file for Rust projects

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages