Trait CloneAsFreshTemporary

Source
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 is Some(...) in the original workspace, we copy all relevant directories/files from the old temporary location to a new TempDir.
  • If temp_dir is None, meaning this workspace wasn’t “ephemeral”, we still create a new TempDir 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

  1. Performance: Copying all directories/files can be expensive for large workspaces.
  2. Divergence: Once cloned, the new workspace will not share changes with the original.
  3. Potential Partial Copy: You might want to selectively copy only certain subdirectories or files. That requires custom logic.
  4. Error Handling: Below is a fairly minimal approach to handle typical I/O errors. Adjust as needed for production usage.

Required Methods§

Source

fn clone_as_fresh_temp(&self) -> Result<Self, Error>
where Self: Sized,

Implementors§

Source§

impl CloneAsFreshTemporary for BatchWorkspace

The robust approach for “deep cloning” a workspace into a new TempDir.