commit | 968dd5c2b3a7d1507815c6d33a5ab123e8381632 | [log] [tgz] |
---|---|---|
author | Linux Build Service Account <lnxbuild@localhost> | Wed Feb 16 21:43:15 2022 -0800 |
committer | Linux Build Service Account <lnxbuild@localhost> | Wed Feb 16 21:43:15 2022 -0800 |
tree | b9c7006c5862676a8640e6f100c79e1ba7d880a2 | |
parent | 382ac0afec6546cdbe042bdd3535fd64d94790f2 [diff] | |
parent | 63b1de0e0e88495c9f7f08ff52490943a3a59176 [diff] |
Merge 63b1de0e0e88495c9f7f08ff52490943a3a59176 on remote branch Change-Id: Ic091cc560b3df3e281fd83e2dd53840c39959647
A secure, cross-platform, temporary file library for Rust. 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.40.0
Add this to your Cargo.toml
:
[dependencies] tempfile = "3"
use std::fs::File; use std::io::{Write, Read, Seek, SeekFrom}; fn main() { // Write let mut tmpfile: File = tempfile::tempfile().unwrap(); write!(tmpfile, "Hello World!").unwrap(); // Seek to start tmpfile.seek(SeekFrom::Start(0)).unwrap(); // Read let mut buf = String::new(); tmpfile.read_to_string(&mut buf).unwrap(); assert_eq!("Hello World!", buf); }