Expand description
Byte-range splicer for the workload edit primitive.
Once super::locate tells us where to make a
change, this module emits the new bytes that go in.
Three operations:
replace_range— overwrite an existing value’s byte range (replace-style edits, e.g.--add --replace).insert_at— insert new content at an offset (add-new-key edits, e.g.--addwith a missing anchor).indent_block— re-indent a multi-line block of text to a given column. Used to align emitted YAML to the locator-reported indent.
Each function returns the post-splice source string;
it doesn’t write to disk. The transactional driver in
super does the on-disk rename via
super::backup::commit_temp.
Functions§
- indent_
block - Re-indent
blockto start every non-empty line at columncolumn. Existing leading whitespace on each line is replaced by exactlycolumnspaces. - insert_
at - Insert
new_contentatoffset. Equivalent toreplace_range(original, offset..offset, new_content), expressed plainly because insertion is the common case for adding new keys. - replace_
range - Replace
original[range]withreplacement. The ranges either side are preserved byte-for-byte.