Zillowe FoundationZillowe Documentation

Getting Started

Learn how to use zbsdiff to create and apply patches.

Creating a Patch

To create a patch, use the Bsdiff struct. It requires the source data and the target data as byte slices.

use std::io;
use zbsdiff::Bsdiff;

fn main() -> io::Result<()> {
    let source = b"Hello, world!";
    let target = b"Hello, Rust world!";
    let mut patch = Vec::new();

    Bsdiff::new(source, target)
        .compare(io::Cursor::new(&mut patch))?;

    println!("Patch size: {} bytes", patch.len());
    Ok(())
}

Applying a Patch

To apply a patch, use the Bspatch struct.

use std::io;
use zbsdiff::Bspatch;

fn main() -> io::Result<()> {
    let source = b"Hello, world!";
    let patch = // ... load patch data ...;
    let mut output = Vec::new();

    let patcher = Bspatch::new(&patch)?;
    
    // Optional: Preallocate target buffer
    output.reserve(patcher.hint_target_size() as usize);

    patcher.apply(source, io::Cursor::new(&mut output))?;

    assert_eq!(output, b"Hello, Rust world!");
    Ok(())
}

A software organization

2026 © All Rights Reserved.

  • All the content is available under CC BY-SA 4.0, expect where otherwise stated.

Last updated on