commit | 108f6ef9a0cca422657e4ea2d456e2fbb4743d9a | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Fri Nov 12 07:56:39 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Nov 12 07:56:39 2021 +0000 |
tree | fcb396b07e23f89a3426f986166cc84224552920 | |
parent | 902e53ef4939c9b3d1220b6527adb954a8c051e8 [diff] | |
parent | b4efe675559a2a73cf98e4ecd4d033991ffede8b [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/tempfile am: 79baa53add am: 819379d50e am: db2f09c485 am: b4efe67555 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/tempfile/+/1889361 Change-Id: I879acedaffdc7433ea955bd29abeef86382317fe
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); }