pub struct CapturedArtifact { /* private fields */ }Expand description
Owned copy of one completed producer output, independent of later source replacement.
Keep this record alive through every use of Self::path. The copy is
temporary rather than a reusable cache entry; ordinary Drop removes it.
Self::retain explicitly transfers cleanup to the caller.
Implementations§
Source§impl CapturedArtifact
impl CapturedArtifact
Sourcepub fn capture(
source: &Path,
parent: &Path,
maximum_bytes: usize,
) -> Result<Self>
pub fn capture( source: &Path, parent: &Path, maximum_bytes: usize, ) -> Result<Self>
Capture an output synchronously before another producer can overwrite it.
The caller keeps the source stable during capture and selects the maximum readable byte count. Read/publication failures retain their typed causes inside the returned I/O error. Existing public destinations are untouched. Bytes stream through bounded scratch rather than a complete in-memory copy.
§Errors
Returns the source read/byte-limit, staging allocation or durable-write error. An unsuccessful capture performs best-effort staging cleanup.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Borrow the exact captured bytes while this record owns their lifetime.
Sourcepub fn retain(self) -> PathBuf
pub fn retain(self) -> PathBuf
Transfer the captured file and its staging child to caller-owned retention.
Unlike close or Drop, this keeps the exact captured bytes after this owner is consumed. The caller owns later cleanup of the returned path’s parent. Keep custody of those paths; this grants no cache or release admission.
Sourcepub fn retain_to(
self,
destination: &Path,
) -> Result<PathBuf, CaptureRetentionError>
pub fn retain_to( self, destination: &Path, ) -> Result<PathBuf, CaptureRetentionError>
Retain the exact capture at a caller-selected destination.
Uses fs::rename semantics, including replacement of an existing
destination when supported. The caller owns destination admission and
later custody. Only the empty owned staging child is removed on success.
§Errors
Rename or cleanup failure reports the actual retained bytes and staging child. Neither failure deletes evidence or silently retries publication.