commit | c9ddf2112a57b7a0ed95e7fa709db48d107b63bf | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Fri May 26 10:19:37 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Fri May 26 10:19:37 2023 +0000 |
tree | 95cb488307c04b8942d85975d0676fb4c1e1ce04 | |
parent | 21022c60b8fae5f935b66a6cb2f8a760f6e13cef [diff] | |
parent | a8e9ddec5055215979b8999ade9eb5a2b4cde18e [diff] |
Snap for 10209341 from a8e9ddec5055215979b8999ade9eb5a2b4cde18e to mainline-healthfitness-release Change-Id: I106d79a96f9c06477214fac6c93af7ba045accbe
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); }