pub struct TempFile(/* private fields */);Expand description
A temporary file.
A temporary file, generated with tempfile crate.
Methods from Deref<Target = NamedTempFile>§
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Get the temporary file’s path.
§Security
Referring to a temporary file’s path may not be secure in all cases. Please read the security section on the top level documentation of this type for details.
§Examples
use tempfile::NamedTempFile;
let file = NamedTempFile::new()?;
println!("{:?}", file.path());Sourcepub fn reopen(&self) -> Result<File, Error>
pub fn reopen(&self) -> Result<File, Error>
Securely reopen the temporary file.
This function is useful when you need multiple independent handles to
the same file. It’s perfectly fine to drop the original NamedTempFile
while holding on to Files returned by this function; the Files will
remain usable. However, they may not be nameable.
§Errors
If the file cannot be reopened, Err is returned.
§Security
Unlike File::open(my_temp_file.path()), NamedTempFile::reopen()
guarantees that the re-opened file is the same file, even in the
presence of pathological temporary file cleaners.
§Examples
use tempfile::NamedTempFile;
let file = NamedTempFile::new()?;
let another_handle = file.reopen()?;