zbsdiff-cli 1.5.2

CLI tools for zbsdiff
zbsdiff-cli-1.5.2 is not a library.

zbsdiff

Crates.io Version

Fast and memory saving bsdiff 4.x compatible delta compressor and patcher, fork of qbsdiff.

This project is a Rust workspace containing:

  • zbsdiff: The core library for diffing and patching.
  • zbsdiff-cli: Command-line tools for manual operations.
  • zbsdiff-test-utils: Internal testing and benchmarking helpers.

Add library dependency to Cargo.toml:

[dependencies]
zbsdiff = "1.5"

Features

  • Performance: Optimized for speed and low memory usage.
  • Parallelization: Supports multi-threaded diffing with fixed-size or Content-Defined Chunking (CDC) schemes.
  • Extensibility: Decoupled diffing engine and storage format via PatchWriter and PatchReader traits. Use any compressor (zstd, gzip, etc.) by implementing the traits.

Build commands

Build the zbsdiff and zbspatch CLI tools:

cargo build --release -p zbsdiff-cli
cd target/release
./zbsdiff --help
./zbspatch --help

Install commands to $CARGO_HOME/bin:

cargo install zbsdiff-cli

Examples

Produce the target stream by applying patch to source:

use std::io;
use zbsdiff::Bspatch;

fn bspatch(source: &[u8], patch: &[u8]) -> io::Result<Vec<u8>> {
    let patcher = Bspatch::new(patch)?;
    let mut target = Vec::new();
    patcher.apply(source, io::Cursor::new(&mut target))?;
    Ok(target)
}

Produce the patch data by comparing source with target:

use std::io;
use zbsdiff::Bsdiff;

fn bsdiff(source: &[u8], target: &[u8]) -> io::Result<Vec<u8>> {
    let mut patch = Vec::new();
    Bsdiff::new(source, target)
        .compare(io::Cursor::new(&mut patch))?;
    Ok(patch)
}

Note that zbsdiff would not generate exactly the same patch file as bsdiff. Only the patch file format is promised to be compatible.

License

Licensed under either of

at your option.