commit | a07273e347a81fbfed3a9038db2530085a3aab8c | [log] [tgz] |
---|---|---|
author | Jiyong Park <jiyong@google.com> | Thu Nov 11 11:42:36 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Thu Nov 11 11:42:36 2021 +0000 |
tree | e038b71ecdc56705a9ed09e0058699be730091e7 | |
parent | 19c4785cdd2f1bba2a0c979405cb056a576612b2 [diff] | |
parent | 4072b272def5821e1bc8f4810feea855fe17a073 [diff] |
Update Android.bp with cargo2android.json am: 72255bb1cc am: 5c8636b7d6 am: 5b2c7fa591 am: 4072b272de Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/tempfile/+/1877216 Change-Id: Ifd44e1268745c9782b9516f18c7bdcb7e8ed5314
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); }