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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TempDir
impl RefUnwindSafe for TempDir
impl Send for TempDir
impl Sync for TempDir
impl Unpin for TempDir
impl UnwindSafe for TempDir
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more