[][src]Struct qbsdiff::bsdiff::Bsdiff

pub struct Bsdiff<'s, 't> { /* fields omitted */ }

Fast and memory saving bsdiff 4.x compatible delta compressor for execuatbles.

Source data size should not be greater than MAX_LENGTH (about 4 GiB).

Compares source with target and generates patch using the best compression level:

use std::io;
use qbsdiff::{Bsdiff, Compression};

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

Methods

impl<'s, 't> Bsdiff<'s, 't>[src]

pub fn new(source: &'s [u8], target: &'t [u8]) -> Self[src]

Create new configuration for bsdiff delta compression.

Panics if the length of source data is greater than MAX_LENGTH.

pub fn source(self, s: &'s [u8]) -> Self[src]

Set the source data.

pub fn target(self, t: &'t [u8]) -> Self[src]

Set the target data.

pub fn parallel_scheme(self, scheme: ParallelScheme) -> Self[src]

Set parrallel searching scheme (default is ParallelScheme::Never). Chunk size or thread number should not be zero, or it would automatically choose a proper number instead.

Considering that small chunk size of each parallel job may lead to bad patch quality, the chunk size is forced to be no less than 256 KiB internally.

pub fn small_match(self, sm: usize) -> Self[src]

Set the threshold to determine small match (default is SMALL_MATCH). If set to zero, no matches would be skipped.

pub fn compression_level(self, lv: Compression) -> Self[src]

Set the compression level of bzip2 (default is LEVEL).

pub fn buffer_size(self, bs: usize) -> Self[src]

Set the buffer size for delta calculation (bs >= 128, default is BUFFER_SIZE).

pub fn compare<P: Write>(&self, patch: P) -> Result<u64>[src]

Start searching matches in target and constructing the patch file.

The size of patch file would be returned if no error occurs.

Auto Trait Implementations

impl<'s, 't> RefUnwindSafe for Bsdiff<'s, 't>

impl<'s, 't> Send for Bsdiff<'s, 't>

impl<'s, 't> Sync for Bsdiff<'s, 't>

impl<'s, 't> Unpin for Bsdiff<'s, 't>

impl<'s, 't> UnwindSafe for Bsdiff<'s, 't>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.