[][src]Crate qbsdiff

Fast and memory saving bsdiff 4.x compatible delta compressor and patcher.

Add dependency to Cargo.toml:

[dependencies]
qbsdiff = "1.3"

Build commands

The commands qbsdiff and qbspatch could be compiled with:

$ cargo build --release --bins --features cmd
$ target/release/qbsdiff -h
$ target/release/qbspatch -h

Examples

Apply patch to source and produce the target data:

use std::io;
use qbsdiff::Bspatch;

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

Compare source with target then generate patch:

use std::io;
use qbsdiff::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 qbsdiff would not generate exactly the same patch file as bsdiff. Only the patch file format is promised to be compatible.

Re-exports

pub use bsdiff::Bsdiff;
pub use bsdiff::ParallelScheme;
pub use bspatch::Bspatch;

Modules

bsdiff
bspatch

Enums

Compression

When compressing data, the compression level can be specified by a value in this enum.