pub trait CloneAsFreshTemporary {
// Required method
fn clone_as_fresh_temp(&self) -> Result<Self, Error>
where Self: Sized;
}
Expand description
A trait defining how to “deep clone” a BatchWorkspace
into a fully fresh temporary directory,
replicating its directory structure (workdir, logs, done, etc.), as well as copying over any
existing files.
- If
temp_dir
isSome(...)
in the original workspace, we copy all relevant directories/files from the old temporary location to a newTempDir
. - If
temp_dir
isNone
, meaning this workspace wasn’t “ephemeral”, we still create a newTempDir
for the clone. We then copy the source workspace’s directories into this newly created temporary location. In effect, the clone always gets an independent ephemeral environment.
Thus, regardless of whether the original is ephemeral or permanent, the resulting clone is always
ephemeral (with its own TempDir
), containing a deep copy of the original workspace’s layout
and files.
§Important Caveats
- Performance: Copying all directories/files can be expensive for large workspaces.
- Divergence: Once cloned, the new workspace will not share changes with the original.
- Potential Partial Copy: You might want to selectively copy only certain subdirectories or files. That requires custom logic.
- Error Handling: Below is a fairly minimal approach to handle typical I/O errors. Adjust as needed for production usage.
Required Methods§
fn clone_as_fresh_temp(&self) -> Result<Self, Error>where
Self: Sized,
Implementors§
impl CloneAsFreshTemporary for BatchWorkspace
The robust approach for “deep cloning” a workspace into a new TempDir
.