• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/25-Apr-2025-2,8951,203

tests/25-Apr-2025-1,083855

.cargo-checksum.jsonD25-Apr-20252.2 KiB11

Android.bpD25-Apr-2025956 3834

CHANGELOG.mdD25-Apr-20258.3 KiB291183

Cargo.tomlD25-Apr-20251.9 KiB9176

LICENSED25-Apr-202510.6 KiB202169

LICENSE-APACHED25-Apr-202510.6 KiB202169

LICENSE-MITD25-Apr-20251 KiB2622

METADATAD25-Apr-2025397 1817

MODULE_LICENSE_APACHE2D25-Apr-20250

README.mdD25-Apr-20251.2 KiB4734

TEST_MAPPINGD25-Apr-2025661 3029

cargo_embargo.jsonD25-Apr-2025143 98

deny.tomlD25-Apr-2025545 3428

README.md

1tempfile
2========
3
4[![Crate](https://img.shields.io/crates/v/tempfile.svg)](https://crates.io/crates/tempfile)
5[![Build Status](https://github.com/Stebalien/tempfile/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Stebalien/tempfile/actions/workflows/ci.yml?query=branch%3Amaster)
6
7A secure, cross-platform, temporary file library for Rust. In addition to creating
8temporary files, this library also allows users to securely open multiple
9independent references to the same temporary file (useful for consumer/producer
10patterns and surprisingly difficult to implement securely).
11
12[Documentation](https://docs.rs/tempfile/)
13
14Usage
15-----
16
17Minimum required Rust version: 1.63.0
18
19Add this to your `Cargo.toml`:
20
21```toml
22[dependencies]
23tempfile = "3"
24```
25
26Example
27-------
28
29```rust
30use std::fs::File;
31use std::io::{Write, Read, Seek, SeekFrom};
32
33fn main() {
34    // Write
35    let mut tmpfile: File = tempfile::tempfile().unwrap();
36    write!(tmpfile, "Hello World!").unwrap();
37
38    // Seek to start
39    tmpfile.seek(SeekFrom::Start(0)).unwrap();
40
41    // Read
42    let mut buf = String::new();
43    tmpfile.read_to_string(&mut buf).unwrap();
44    assert_eq!("Hello World!", buf);
45}
46```
47