Migrate to cargo_embargo. am: e71283ced1 am: 4fabc5dd7b am: 1c5ccae1a8

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/tempfile/+/2838295

Change-Id: Id999436ef85d2774cf8b0c920313ccc7afc56fc3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
tree: 9eb61c3b3b73d6edbf72dd37f68570b83f4cfecf
  1. .github/
  2. src/
  3. tests/
  4. .cargo_vcs_info.json
  5. .gitignore
  6. Android.bp
  7. Cargo.toml
  8. Cargo.toml.orig
  9. cargo_embargo.json
  10. LICENSE-APACHE
  11. LICENSE-MIT
  12. METADATA
  13. MODULE_LICENSE_APACHE2
  14. NEWS
  15. OWNERS
  16. README.md
  17. TEST_MAPPING
README.md

tempfile

Crate Build Status

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).

Documentation

Usage

Minimum required Rust version: 1.40.0

Add this to your Cargo.toml:

[dependencies]
tempfile = "3"

Example

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);
}