Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

sunsided/async-tempfile-rs

Repository files navigation

async-tempfile

Crates.io Crates.io GitHub Workflow Status docs.rs codecov

Provides the TempFile struct, an asynchronous wrapper based on tokio::fs for temporary files that will be automatically deleted when the last reference to the struct is dropped.

use async_tempfile::TempFile;
#[tokio::main]
async fn main() {
 let parent = TempFile::new().await.unwrap();
 // The cloned reference will not delete the file when dropped.
 {
 let nested = parent.open_rw().await.unwrap();
 assert_eq!(nested.file_path(), parent.file_path());
 assert!(nested.file_path().is_file());
 }
 // The file still exists; it will be deleted when `parent` is dropped.
 assert!(parent.file_path().is_file());
}

About

Automatically deleted async I/O temporary files in Rust

Topics

Resources

License

Stars

Watchers

Forks

Languages

AltStyle によって変換されたページ (->オリジナル) /