Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 20-Jan-2022 | - | ||||
src/ | H | 20-Jan-2022 | - | 2,414 | 867 | |
tests/ | H | 20-Jan-2022 | - | 918 | 739 | |
.cargo-checksum.json | H A D | 03-May-2022 | 89 | 1 | 1 | |
Cargo.toml | H A D | 20-Jan-2022 | 1.4 KiB | 40 | 36 | |
LICENSE-APACHE | H A D | 20-Jan-2022 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | H A D | 20-Jan-2022 | 1 KiB | 26 | 22 | |
NEWS | H A D | 20-Jan-2022 | 4 KiB | 192 | 124 | |
README.md | H A D | 20-Jan-2022 | 1.3 KiB | 47 | 35 |
README.md
1tempfile 2======== 3 4[![Crate](https://img.shields.io/crates/v/tempfile.svg)](https://crates.io/crates/tempfile) 5[![Build Status](https://travis-ci.org/Stebalien/tempfile.svg?branch=master)](https://travis-ci.org/Stebalien/tempfile) 6[![Build status](https://ci.appveyor.com/api/projects/status/5q00b8rvvg46i5tf/branch/master?svg=true)](https://ci.appveyor.com/project/Stebalien/tempfile/branch/master) 7 8A secure, cross-platform, temporary file library for Rust. In addition to creating 9temporary files, this library also allows users to securely open multiple 10independent references to the same temporary file (useful for consumer/producer 11patterns and surprisingly difficult to implement securely). 12 13[Documentation](https://docs.rs/tempfile/) 14 15Usage 16----- 17 18Minimum required Rust version: 1.40.0 19 20Add this to your `Cargo.toml`: 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