pub enum WorkDir {
Persistent(PathBuf),
Temporary(TempDir),
}Expand description
A directory whose existence is guaranteed while this value is alive.
Use WorkDir::persistent for user-specified paths (no cleanup)
and WorkDir::temporary for auto-generated directories (cleanup on drop).
Variants§
Persistent(PathBuf)
User-specified directory. Not deleted on drop.
Temporary(TempDir)
Auto-generated temporary directory. Deleted on drop via tempfile::TempDir.
Implementations§
Source§impl WorkDir
impl WorkDir
Sourcepub fn persistent(path: PathBuf) -> Result<WorkDir, Error>
pub fn persistent(path: PathBuf) -> Result<WorkDir, Error>
Create a WorkDir backed by a user-specified path.
Creates the directory (and parents) if it does not exist.
§Errors
Returns std::io::Error if directory creation fails.
Sourcepub fn temporary() -> Result<WorkDir, Error>
pub fn temporary() -> Result<WorkDir, Error>
Create a WorkDir backed by a temporary directory.
The directory is created with a cryptographically random name
(via tempfile::tempdir) and is automatically deleted when
the WorkDir is dropped.
§Errors
Returns std::io::Error if temporary directory creation fails.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Returns the path to the work directory.
The path is valid for as long as this WorkDir value is alive.
Sourcepub fn is_temporary(&self) -> bool
pub fn is_temporary(&self) -> bool
Returns true if this is a temporary (auto-cleanup) directory.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WorkDir
impl RefUnwindSafe for WorkDir
impl Send for WorkDir
impl Sync for WorkDir
impl Unpin for WorkDir
impl UnsafeUnpin for WorkDir
impl UnwindSafe for WorkDir
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