Crates.io | qbsdiff |
lib.rs | qbsdiff |
version | 1.4.2 |
source | src |
created_at | 2019-10-17 09:51:36.374196 |
updated_at | 2024-04-15 06:57:15.399188 |
description | Fast and memory saving bsdiff 4.x compatible delta compressor and patcher. |
homepage | https://github.com/hucsmn/qbsdiff |
repository | https://github.com/hucsmn/qbsdiff |
max_upload_size | |
id | 173288 |
size | 80,584 |
Fast and memory saving bsdiff 4.x compatible delta compressor and patcher.
Add dependency to Cargo.toml
:
[dependencies]
qbsdiff = "1.4"
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
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.