#tempfile #tmpfile #camino


A library for managing temporary files and directories, with UTF-8 paths

1 stable release

1.0.2 Apr 24, 2023

#518 in Filesystem

Download history 1633/week @ 2023-06-05 1566/week @ 2023-06-12 1625/week @ 2023-06-19 7621/week @ 2023-06-26 5850/week @ 2023-07-03 7349/week @ 2023-07-10 5296/week @ 2023-07-17 6055/week @ 2023-07-24 7238/week @ 2023-07-31 21322/week @ 2023-08-07 12123/week @ 2023-08-14 27402/week @ 2023-08-21 22655/week @ 2023-08-28 5684/week @ 2023-09-04 7212/week @ 2023-09-11 8268/week @ 2023-09-18

44,091 downloads per month
Used in 7 crates (2 directly)


507 lines


camino-tempfile on crates.io Documentation (latest release) Documentation (main) License License

A secure, cross-platform, temporary file library for Rust with UTF-8 paths.

This crate is a wrapper around tempfile that works with the Utf8Path and Utf8PathBuf types defined by camino. If your code mostly uses camino, it can be annoying to have to convert temporary paths to Utf8Path over and over again. This crate manages that for you.

In addition to creating temporary files, this library also allows users to securely open multiple independent references to the same temporary file (useful for consumer/producer patterns and surprisingly difficult to implement securely).



Minimum required Rust version: 1.48.0

Add this to your Cargo.toml:

camino-tempfile = "1"


use std::fs::File;
use std::io::{Write, Read, Seek, SeekFrom};

fn main() {
    // Write
    let mut tmpfile: File = camino_tempfile::tempfile().unwrap();
    write!(tmpfile, "Hello World!").unwrap();

    // Seek to start

    // Read
    let mut buf = String::new();
    tmpfile.read_to_string(&mut buf).unwrap();
    assert_eq!("Hello World!", buf);


This project is available under the terms of either the Apache 2.0 license or the MIT license.

Portions copied and adapted from tempfile and used under the MIT and Apache 2.0 licenses. tempfile is copyright 2015 Steven Allen and the tempfile authors.


~91K SLoC