pub fn patch_tape<T: TapeSource>(
source_tape: &T,
diff: &TapeDiff<'_>,
) -> Result<Value>Expand description
Full pipeline: apply diff from tape_b to value derived from tape_a
This is the common use case for cross-format patching:
- Parse both documents as tapes
- Compute diff between tapes (fast!)
- Convert source tape to Value
- Apply diff to Value
§Example
ⓘ
let tape_a = UnifiedTape::parse(yaml_a.as_bytes(), FormatKind::Yaml)?;
let tape_b = UnifiedTape::parse(yaml_b.as_bytes(), FormatKind::Yaml)?;
let diff = diff_tapes(&tape_a, &tape_b)?;
let patched = patch_tape(&tape_a, &diff)?;
// patched is now equivalent to tape_b's data§Errors
Returns an error if the source tape cannot be converted or the diff cannot be applied.