Crate ina

Source
Expand description

Binary diffing and patching designed for executables.

This crate provides simple interfaces for creating binary deltas between arbitrary blobs and applying them to reconstruct the original blob. It is especially well-suited for executable files, i.e., it is designed to produce small deltas specifically for executables.

§Examples

Creating a patch file between two executable versions:

use std::fs::{self, File};

let mut old = fs::read("app-v1.exe")?;
// Ensure the last byte is a 0
old.push(0);
let new = fs::read("app-v2.exe")?;
let mut patch = File::create("app-v1-to-v2.ina")?;

ina::diff(&old, &new, &mut patch)?;

Applying a patch file to create an updated executable:

use std::{io, fs::File};

let old = File::open("app-v1.exe")?;
let patch = File::open("app-v1-to-v2.ina")?;
let mut new = File::create("app-v2.exe")?;

ina::patch(old, patch, &mut new)?;

Structs§

DiffConfig
Configuration for a diff operation.
PatchMetadata
Metadata of a patch file.
PatchVersion
Version of a patch file format.
Patcher
A patcher that reconstructs a new blob from an old blob and a patch

Enums§

PatchError
An error indicating that patching a blob failed.

Functions§

diff
Constructs a patch between two blobs with default options
diff_with_config
Constructs a patch between two blobs
patch
Reconstructs a new blob from an old blob and a patch
read_header
Reads the header of patch to extract its metadata.