6个版本 (破坏性更新)

0.6.0 2024年6月30日
0.5.0 2023年12月6日
0.4.0 2023年6月16日
0.3.0 2023年6月12日
0.1.0 2022年10月22日

#125 in 异步

Download history · Rust 包仓库 4226/week @ 2024-05-03 · Rust 包仓库 4903/week @ 2024-05-10 · Rust 包仓库 5140/week @ 2024-05-17 · Rust 包仓库 5194/week @ 2024-05-24 · Rust 包仓库 5907/week @ 2024-05-31 · Rust 包仓库 5701/week @ 2024-06-07 · Rust 包仓库 4979/week @ 2024-06-14 · Rust 包仓库 5460/week @ 2024-06-21 · Rust 包仓库 5036/week @ 2024-06-28 · Rust 包仓库 4832/week @ 2024-07-05 · Rust 包仓库 5054/week @ 2024-07-12 · Rust 包仓库 5612/week @ 2024-07-19 · Rust 包仓库 5996/week @ 2024-07-26 · Rust 包仓库 6941/week @ 2024-08-02 · Rust 包仓库 6733/week @ 2024-08-09 · Rust 包仓库 4775/week @ 2024-08-16 · Rust 包仓库

每月25,687次下载
5 crates 中使用

MIT 许可证

39KB
496

async-tempfile

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

提供TempFile结构体,它是一个基于tokio::fs的异步包装器,用于临时文件,当最后一个对该结构体的引用被丢弃时,将自动删除。

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

依赖

~2–3MB
~47K SLoC