commit | 4578b5b3b34d2dc74034747ceda1ebffa9c9acc5 | [log] [tgz] |
---|---|---|
author | Jeff Vander Stoep <jeffv@google.com> | Mon Feb 06 09:09:48 2023 +0100 |
committer | Jeff Vander Stoep <jeffv@google.com> | Mon Feb 06 09:09:48 2023 +0100 |
tree | 632a499f62c12dc7f097c0214344371ef9d8384c | |
parent | 05984ae3288310c34218fbeaf6e114f3881cd406 [diff] |
Upgrade tempfile to 3.3.0 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/tempfile For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md Test: TreeHugger Change-Id: Ida34064265fa66471afd5f1c831a627779165d2e
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); }