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:PatchRequestdescribing target file, key (with aliases), value, and dry-run flag.
Output:
PatchOutcome::NoChangewhen the file already holds the requested value.PatchOutcome::Writtenwhen the file was updated atomically.PatchOutcome::DryRunwhenreq.dry_runistrueand a change would have been made.
ยงErrors
ConfigWriteError::Invalidwhenreq.keyis empty after trimming.ConfigWriteError::Iowhen reading the existing file or performing the atomic temp-file write/rename fails.
Details:
- Comments and unrelated keys are preserved: only the matched line is
rewritten in place. When no existing line matches, the canonical
key = valuepair 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, mode0o600on Unix), so a partially-written file is never visible.