Skip to main content

patch_delta

Function patch_delta 

Source
pub fn patch_delta(
    base: &[u8],
    delta: &[u8],
) -> Result<Vec<u8>, DiffDecodeError>
Expand description

Recreates the target from the base and encoded delta.

§Errors

Fails if delta is invalid, doesn’t match base, or the target is too large to fit into memory.

let base = "This is a pure rust implementation of Git's delta compression algorithm.";
let target = base.replace("Git", "git");
let delta = git_pack_delta::create_delta(base.as_bytes(), target.as_bytes()).unwrap();
let target2 = git_pack_delta::patch_delta(base.as_bytes(), &delta).unwrap();
assert_eq!(target.as_bytes(), target2);