pub struct Snapshot { /* private fields */ }Expand description
One run’s snapshot directory, claimed when the run first needs it.
Implementations§
Source§impl Snapshot
impl Snapshot
Sourcepub fn begin(canonical_target: &Path) -> Result<Self, RkError>
pub fn begin(canonical_target: &Path) -> Result<Self, RkError>
Claim the snapshot directory for one run against canonical_target.
A caller begins a snapshot only at its first destructive step, so a run that saves nothing claims nothing.
§Errors
A prerequisite-unmet refusal where no state root resolves, because
a destructive step that cannot save first does not run, and
RkError::Io where the directory cannot be created.
Sourcepub const fn at(root: PathBuf) -> Self
pub const fn at(root: PathBuf) -> Self
A snapshot rooted at root, for a workspace that names its own.
Sourcepub fn save(&self, relative: &Path, bytes: &[u8]) -> Result<PathBuf, RkError>
pub fn save(&self, relative: &Path, bytes: &[u8]) -> Result<PathBuf, RkError>
Save bytes at relative below the snapshot, owner-only, and
return where. A copy already standing there with the same bytes is
kept; one with other bytes refuses, because overwriting a backup
loses the bytes it exists to keep.
§Errors
A state-drift refusal for a saved copy with other bytes, and
RkError::Io for a write that fails.