Skip to main content

patch_key

Function patch_key 

Source
pub fn patch_key(
    req: &PatchRequest<'_>,
) -> Result<PatchOutcome, ConfigWriteError>
Expand description

What: Apply a single key/value patch to a Pacsea config file.

Inputs:

  • req: PatchRequest describing target file, key (with aliases), value, and dry-run flag.

Output:

ยงErrors

Details:

  • Comments and unrelated keys are preserved: only the matched line is rewritten in place. When no existing line matches, the canonical key = value pair is appended.
  • Aliases are migrated in the same pass: an alias line on disk is rewritten with the primary key.
  • File is bootstrapped from the matching skeleton when missing or empty.
  • Writes go through [atomic_write] (temp file + rename, mode 0o600 on Unix), so a partially-written file is never visible.