commit | 24c4466a748d959ae31059717ab2627dfd857c61 | [log] [tgz] |
---|---|---|
author | David Brazdil <dbrazdil@google.com> | Mon Jan 23 14:07:37 2023 +0000 |
committer | David Brazdil <dbrazdil@google.com> | Mon Jan 23 14:07:37 2023 +0000 |
tree | c4cc6c8e36f8f0e80500a5129e34a00d56e70dcb | |
parent | 4d546ca6478cdd29788cc3677cf92b2f19f8a891 [diff] |
Update TEST_MAPPING Test: None Change-Id: I1609388ec6a3c9dd336b9d49f3b5eb2263e599eb
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); }