Skip to main content

apply_plan

Function apply_plan 

Source
pub fn apply_plan(
    plan: &UpdatePlan,
    path: &Path,
    original_content: &str,
    dry_run: DryRun,
) -> Result<(), ApplyError>
Expand description

Applies plan’s Outcome::Applied edits to path, whose content the plan’s ranges were computed against was original_content (FR-016 through FR-020).

Always re-reads and byte-compares path against original_content before writing (FR-019) — even under dry_run, so a --dry-run report never claims success for a plan a following real run would actually reject. crate::format::DryRun::Yes skips the deps_core::fs_probe::write_atomic call itself; so does a plan whose edits would produce byte-identical content (no Applied items, or all-no-op edits) — skipping an unnecessary rewrite avoids churning the file’s mtime/inode for file watchers and rebuild systems (critic finding M3).

§Errors

Returns ApplyError::StaleManifest if path’s content no longer matches original_content, ApplyError::Read if the re-read fails, or ApplyError::Write if deps_core::fs_probe::write_atomic fails (including refusing a symlinked path).