Struct rdiff::BlockHashes
[−]
[src]
pub struct BlockHashes { // some fields omitted }
Used for calculating and re-calculating the differences between two versions of the same file
See the module level documentation for examples on how to use this
Methods
impl BlockHashes
[src]
fn new<R: Read>(data_source: R, block_size: usize) -> Result<BlockHashes>
Create a new BlockHash based on the data in data_source. This method
will create a hash for every block_size
set of bytes in data_source
.
To see the difference after data_source
has been updated, use diff_and_update()
This method returns an error when there is a problem reading from data_source
.
fn diff_and_update<R: Read>(&mut self, new_data: R) -> Result<Diff>
Compare the data in new_data
with the hashes computed from either
the most recent call to diff_and_update()
or when this BlockHashes
was updated
Example
use rdiff::BlockHashes; use std::io::Cursor; let mut hashes = BlockHashes::new(Cursor::new("It was the best of times"), 6).unwrap(); let diff = hashes.diff_and_update(Cursor::new("It was not the best of things")).unwrap(); // prints (6, ' not') and (22, ' things')) for insert in diff.inserts() { println!("{:?}", insert); } // prints (29, 6) for delete in diff.deletes() { println!("{:?}", delete); } assert_eq!("It was not the best of things", diff.apply_to_string("It was the best of times").unwrap());
Trait Implementations
Derived Implementations
impl PartialEq for BlockHashes
[src]
fn eq(&self, __arg_0: &BlockHashes) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BlockHashes) -> bool
This method tests for !=
.