librsync-ffi 0.1.0

opinionated bindings to librsync
Documentation
  • Coverage
  • 0%
    0 out of 5 items documented0 out of 0 items with examples
  • Size
  • Source code size: 17.03 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 445.39 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kvnvelasco

Rust FFI bindings for librsync2

Dynamically linked to librsync2 / librsync-dev

Features

  • Whole File API
    • Generate Signature
    • Load signature into memory
    • Create Delta
    • Apply delta onto file
  • Streaming API
  • Error handling

Usage

File API

Generating a Signature

Signatures are stored in memory even though the whole file api is used. Temporary directories are utilized to hold values until they get initialized in memory.

let path = PathBuf::from("some/file/location");
let (signature, stats) = Signature::new(&path).unwrap;

Generating a delta

Delta files are a Vec<u8> representations of rsync delta files. A delta takes a file signature and some new file to compute against

let path = PathBuf::from("some/file/location");
let (signature, stats) = Signature::new(&path).unwrap;

let some_new_path = PathBuf::from("the/file/changed/maybe");
let (delta, stats) = Delta::new(&mut signature, &some_new_path);

Applying a delta to a file

let path = PathBuf::from("some/file/location");
let (signature, stats) = Signature::new(&path).unwrap;

let some_new_path = PathBuf::from("the/file/changed/maybe");
let (delta, stats) = Delta::new(&mut signature, &some_new_path);

// will output the value of the new file as a Vec<u8> 
let new_file = patch_file(&path, delta);