| Crates.io | aehobak |
| lib.rs | aehobak |
| version | 0.0.17 |
| created_at | 2024-12-18 21:30:59.874158+00 |
| updated_at | 2025-11-24 15:53:26.620227+00 |
| description | Transcoder for bsdiff binary patches. |
| homepage | https://lib.rs/aehobak |
| repository | https://github.com/barrbrain/aehobak |
| max_upload_size | |
| id | 1488490 |
| size | 79,380 |
Aehobak transcodes binary patches from bsdiff.
The goal is a byte-oriented format, compact and optimised for patch application speed.
As compression efficiency is content-dependent, one should verify with a suitable corpus.
The following results are for LZ4-compressed bsdiff patches of build artifacts that are no larger than 3% of the target object size. The bench example can report the same metrics for provided files.
LZ4-compressed aehobak patches yield a median reduction of 63.5%.
Uncompressed aehobak patches yield a median reduction of:
Direct application of aehobak patches can achieve 45% of memcpy speed and is panic-free. Direct generation of aehobak patches takes 69% less time than bsdiff.
let old = vec![1, 2, 3, 4, 5];
let new = vec![1, 2, 4, 6];
let mut patch = Vec::new();
let mut encoded = Vec::new();
bsdiff::diff(&old, &new, &mut patch).unwrap();
aehobak::encode(&patch, &mut encoded).unwrap();
let mut decoded = Vec::with_capacity(patch.len());
let mut patched = Vec::with_capacity(new.len());
aehobak::decode(&mut encoded.as_slice(), &mut decoded).unwrap();
bsdiff::patch(&old, &mut decoded.as_slice(), &mut patched).unwrap();
assert_eq!(patched, new);
fn diff_files(orig_file: &str, file: &str, patch_file: &str) -> std::io::Result<()> {
let old = std::fs::read(orig_file)?;
let new = std::fs::read(file)?;
let mut patch = Vec::new();
aehobak::diff(&old, &new, &mut patch)?;
std::fs::write(patch_file, &patch)
}
fn patch_file(orig_file: &str, patch_file: &str, file: &str) -> std::io::Result<()> {
let old = std::fs::read(orig_file)?;
let patch = std::fs::read(patch_file)?;
let mut new = Vec::with_capacity(10_000_000);
aehobak::patch(&old, &patch, &mut new)?;
std::fs::write(file, &new)
}