BSDIFF40 binary diff and patch library with bounded resources and a native CLI
moon info
moon fmt
moon fmt --check
moon check --target native --deny-warn
moon build --target native
moon test --target native --deny-warn
python scripts/check_format_vectors.py
python scripts/check_compression.py
python scripts/check_apply.py
git diff --checktest "apply-memory-example" {
let stream = b"BZh9\x17\x72\x45\x38\x50\x90\x00\x00\x00\x00"
let patch = b"BSDIFF40" +
b"\x0e\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
stream +
stream +
stream
let limits : @moonbsdiff.Limits = {
max_old_bytes: 1024L,
max_new_bytes: 1024L,
max_patch_bytes: 1024L,
max_output_bytes: 1024L,
max_decompressed_bytes: 4096L,
max_control_instructions: 128L,
max_sort_work: 1L,
max_match_work: 1L,
}
assert_eq(@moonbsdiff.apply(b"", patch, limits), Ok(b""))
}let limits = @moonbsdiff.Limits::for_apply()
// old_bytes and patch_bytes are supplied by the caller.
let result = @moonbsdiff.apply(old_bytes, patch_bytes, limits)test "diff-memory-example" {
let limits : @moonbsdiff.Limits = {
max_old_bytes: 4096L,
max_new_bytes: 4096L,
max_patch_bytes: 8192L,
max_output_bytes: 4096L,
max_decompressed_bytes: 16384L,
max_control_instructions: 256L,
max_sort_work: 1000000L,
max_match_work: 1000000L,
}
let old = b"MoonBSDiff example version 1"
let new = b"MoonBSDiff example version 2!"
let patch = match @moonbsdiff.diff(old, new, limits) {
Ok(b) => b
Err(_) => abort("diff failed")
}
assert_eq(@moonbsdiff.apply(old, patch, limits), Ok(new))
}let limits = @moonbsdiff.Limits::for_diff()
let result = @moonbsdiff.diff(old_bytes, new_bytes, limits)python scripts/build_cli.py& .\_build\bin\windows\moonbsdiff.exe --help
& .\_build\bin\windows\moonbsdiff.exe --version
& .\_build\bin\windows\moonbsdiff.exe diff "old file.bin" "new file.bin" "update.patch"
& .\_build\bin\windows\moonbsdiff.exe patch "old file.bin" "update.patch" "restored file.bin"./_build/bin/linux/moonbsdiff diff 'old file.bin' 'new file.bin' 'update.patch'
./_build/bin/linux/moonbsdiff patch 'old file.bin' 'update.patch' 'restored file.bin'moon run cmd/example --target js
python scripts/run_examples.pypub(all) struct BsdiffError {
kind : ErrorKind
stage : ErrorStage
block : String?
offset : Int64?
field : String?
value : Int64?
limit : Int64?
} derive(Eq, Debug)