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<Self>
pub fn persistent(path: PathBuf) -> Result<Self>
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<Self>
pub fn temporary() -> Result<Self>
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.