commit | ee232a32ac52fcdb40342d71cfb0049bdf103d14 | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Tue Aug 06 16:58:55 2024 +0000 |
committer | James Farrell <[email protected]> | Tue Aug 06 16:58:55 2024 +0000 |
tree | eacc71de8d3f4543d63ab49d45b4efa852047f21 | |
parent | 9370ced250c021c804f7d564de4fd86ffacb3ca2 [diff] |
Update Android.bp by running cargo_embargo Test: ran cargo_embargo Change-Id: Ie3ec270fd51baa5c4b5dcc1ff1114c0a7a37e776
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); }