commit | 575de37192ab9119cc579562b94c5722a65254d6 | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Tue May 21 19:03:25 2024 +0000 |
committer | James Farrell <[email protected]> | Tue May 21 19:03:25 2024 +0000 |
tree | ccb2fe7b0a17aae3effbefcf91934e8ad6b4c9fe | |
parent | 1987df161c483256034630f246a37da098f707f1 [diff] |
Update Android.bp by running cargo_embargo Test: ran cargo_embargo Change-Id: I7c0036389fc262d1e90f1ef48117d9d4b76c5ad2
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); }