#bsdiff #delta

bin+lib qbsdiff

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

11 releases (stable)

1.3.1 Apr 25, 2020
1.3.0 Feb 27, 2020
1.2.1 Dec 5, 2019
1.2.0 Nov 1, 2019
0.1.2 Oct 17, 2019

#64 in Compression

Download history 32/week @ 2021-04-02 12/week @ 2021-04-09 48/week @ 2021-04-16 16/week @ 2021-04-23 26/week @ 2021-04-30 9/week @ 2021-05-07 18/week @ 2021-05-14 21/week @ 2021-05-21 22/week @ 2021-05-28 22/week @ 2021-06-04 23/week @ 2021-06-11 9/week @ 2021-06-18 14/week @ 2021-06-25 11/week @ 2021-07-02 13/week @ 2021-07-09 29/week @ 2021-07-16

201 downloads per month
Used in 3 crates (2 directly)

MIT license

40KB
857 lines

qbsdiff

crates docs dependency status

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

Add dependency to Cargo.toml:

[dependencies]
qbsdiff = "1.3"

Build commands

Build qbsdiff and qbspatch commands:

$ cargo build --release --bins --features cmd
$ cd target/release
$ ./qbsdiff --help
$ ./qbspatch --help

Install commands to $CARGO_HOME/bin:

$ cargo install qbsdiff --features cmd

Examples

Produce the target stream by applying patch to source:

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();
    // To preallocate target:
    //Vec::with_capacity(patcher.hint_target_size() as usize);
    patcher.apply(source, io::Cursor::new(&mut target))?;
    Ok(target)
}

Produce the patch data by comparing source with target:

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.

Dependencies

~2.5MB
~46K SLoC