Giter VIP home page Giter VIP logo

qbsdiff's Introduction

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.4"

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.

qbsdiff's People

Contributors

dylan-dpc avatar hucsmn avatar nbraud avatar nyurik avatar yrashk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qbsdiff's Issues

Allow custom differ and patcher format implementations

bsdiff format uses two somewhat unrelated concepts that fit many, but not all use cases: diffing algorithm and patch storage format.

There are multiple diffing algorithms which could be fine-tuned depending on the data being diffed, resulting in multiple implementations. This is usually the complicated part of the library, requiring a lot of testing and profiling.

Patch storage is far simpler, but may be optimized with different compressions (e.g. brotli), or removal of the magic BSDIFF40 prefix (e.g. in case when there are millions of small diffs being stored in the same sqlite file). Patch storage format is not affected by how the patch was generated.

I would like to discuss how qbsdiff can allow user-implemented patch storage. This way I could choose to have my own compression without the magic prefix, and store the patch in my own envelope format, while qbsdiff would pass me the raw patch data or take patch data and apply it. What do you think?

Progress / cancellation support?

Is there any appetite to enable (optional) support for (at the very least) support for cancellation (something similar to https://github.com/wez/cancel-rs or any other approach that'd work well) and potentially progress reporting (to enable progress tracking for potential cancellation)?

I am happy to try and contribute if that's of interest.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.