pub struct TempDir { /* private fields */ }Expand description
A temporary directory
This create a temporary directory using tempfile::tempdir. It will
generally be cleaned up when the object is dropped.
This type is primarily useful when you need multiple representations (string,
path, object store path) of the same temporary directory. If you only need
a single representation you can use the TempStdDir, TempStrDir, or
TempObjDir types.
Implementations§
Source§impl TempDir
impl TempDir
Sourcepub fn try_new() -> Result<Self>
pub fn try_new() -> Result<Self>
Create a temporary directory, exposing any potential errors.
For most test cases you should use the Default implementation instead.
However, when we use this type in production code, we may want to return
errors gracefully instead of panicking.
Sourcepub fn path_str(&self) -> String
pub fn path_str(&self) -> String
Get the path as a string
This path will be safe to use as a URI on Windows
Sourcepub fn std_path(&self) -> &StdPath
pub fn std_path(&self) -> &StdPath
Get the path as a standard library path
If you convert this to a string, it will NOT be safe to use as a URI on Windows.
Use TempDir::path_str instead.
It is safe to use this as a standard path on Windows.