rdiff

Crates.iordiff
lib.rsrdiff
version0.1.2
sourcesrc
created_at2016-08-04 18:41:34.504966
updated_at2016-09-07 23:30:45.55544
descriptionA library for tracking changes to a file over time
homepagehttps://github.com/dyule/rdiff
repositoryhttps://github.com/dyule/rdiff
max_upload_size
id5893
size67,834
Daniel Yule (dyule)

documentation

https://dyule.github.io/rdiff/rdiff/

README

rdiff

CC0 Build Status Crates.io

rdiff is a package for comparing versions of a file over time. It is written is Rust, and expects version > 1.8.

To the extent possible under law, rdiff contributors have waived all copyright and related or neighboring rights to rdiff.

Documentation

Usage

in Cargo.toml:

[dependencies]
rdiff = "0.1"

In your rust file (taken from examples/predefined.rs):

extern crate rdiff;

use rdiff::BlockHashes;
use std::fs::File;

pub fn example() {
    let file = File::open("examples/filev1.txt").unwrap();
    let mut hashes = BlockHashes::new(file, 8).unwrap();
    let file = File::open("examples/filev2.txt").unwrap();
    let difference = hashes.diff_and_update(file).unwrap();
    println!("Inserts: {:?}", difference.inserts().collect::<Vec<_>>());
    println!("Deletes: {:?}", difference.deletes().collect::<Vec<_>>());
}

This will output

Inserts: [Insert(8, 'widely understood '), Insert(90, ' absolutely'), Insert(381, 'hters, or sons if the family was progressive.\n'), Insert(572, 'not, even though he had been following the news quite closely.\n\n'), Insert(734, '\nMr. Ben')]
Deletes: [Delete(34, 24), Delete(428, 8), Delete(638, 8), Delete(742, 8)]
Commit count: 17

cargo fmt