Skip to main content

apply

Function apply 

Source
pub fn apply(
    resource: &str,
    spec: &RenderSpec,
    committed: &str,
    context: &RenderContext<'_>,
) -> Result<(String, Vec<AppliedReplacement>)>
Expand description

Substitute into committed, the file’s committed content — never what is currently on disk.

That is what makes a render idempotent: reading the working file would mean the second render looks for port = 54321, finds port = 54400, and fails. Reading committed content means undo re-renders off the binding record with no extra machinery, a pull that moves a lane head re-renders from the new content, and values can never compound.

Every find is located in the committed content, and all replacements apply as one batch. A replacement’s output is never a match target. Rewriting in declaration order, re-matching each rule against the partially-rewritten text, would make a rule mean different things depending on what ran before it: a find that happens to equal an earlier rule’s output would either report a spurious second match or silently rewrite that output. Declaration order then stops being cosmetic, which is not a property a config file should have.