green-coder / cdc

A library for performing Content-Defined Chunking (CDC) on data streams.
MIT License
23 stars 5 forks source link
cdc data-stream rust rust-library

cdc

A library for performing Content-Defined Chunking (CDC) on data streams. Implemented using generic iterators, very easy to use.

Example

  let reader: BufReader<File> = BufReader::new(file);
  let byte_iter = reader.bytes().map(|b| b.unwrap());

  // Finds and iterates on the separators.
  for separator in SeparatorIter::new(byte_iter) {
    println!("Index: {}, hash: {:016x}", separator.index, separator.hash);
  }

Each module is documented via an example which you can find in the examples/ folder.

To run them, use a command like:

cargo run --example separator --release

Note: Some examples are looking for a file named myLargeFile.bin which I didn't upload to Github. Please use your own files for testing.

What's in the crate

From low level to high level:

Implementation details

Performance

There is a huge difference between the debug build and the release build in terms of performance. Remember that when you test the lib, use cargo run --release.

I may try to improve the performance of the lib at some point, but for now it is good enough for most usages.

License

Coded with ❤️ , licensed under the terms of the MIT license.