Struct hash_roll::Rsyncable [] [src]

pub struct Rsyncable {
    // some fields omitted
}

'Rsyncable' is used by the gzip rsyncable patch (still not merged, but widely distributed) as well as the rsyncrypto project to split the unerlying content into variable sized blocks prior to applying a filter (compression and/or encryption) to the blocks, which the intent of allowing the resulting filtered data to be more easily propogated via rsync.

No maximum block size is provided. No minimum block size is provided.

PDF of block sizes: ???

Note that the defacto-standard parameters allow a slightly more efficient check for a block split (by replacing a modulus with a bitwise-and). This impl currently doesn't allow that optimization even if you provide appropriate parameters (we need type-level integers for that).

Parameters: window-len: The maximum number of bytes to be examined when deciding to split a block. set to 8192 by default in gzip-rsyncable & rsyncrypto) modulus: set to half of window-len (so, 4096) in gzip-rsyncable & rsyncrypto.

In-block state: window of window-len bytes (use of the iterator interface means we also track more bytes than this) sum (u64)

Between-block state: none

References: http://rsyncrypto.lingnu.com/index.php/Algorithm

S(n) = sum(c_i, var=i, top=n, bottom=n-8196) A(n) = S(n) / 8192 H(n) = S(n) mod 4096

Trigger splits when H(n) == 0

FIXME: Operating using iterators (like this) generally means we'll end up copying the data a number of times (not ideal). The interface may be adjusted (or an additional one provided) in the future to avoid performing the extra copies by working with an underlying slice directly.

Methods

impl Rsyncable
[src]

fn new() -> Rsyncable

fn with_window_and_modulus(window: usize, modulus: u64) -> Rsyncable

Trait Implementations

impl Debug for Rsyncable
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Clone for Rsyncable
[src]

fn clone(&self) -> Rsyncable

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Splitter for Rsyncable
[src]

fn split<'a, 'b>(&'a self, data: &'b [u8]) -> (&'b [u8], &'b [u8])

Split data into 2 pieces using a given splitter. Read more

fn next_iter<'a, T: Iterator<Item=u8>>(&'a self, iter: T) -> Option<Vec<u8>>

Return chunks from a given iterator, split according to the splitter used.

fn into_slices<'a>(self, data: &'a [u8]) -> SplitterSplit<'a, Self> where Self: Sized

fn as_slices<'a>(&'a self, data: &'a [u8]) -> SplitterSplit<'a, &Self> where Self: Sized

fn into_vecs<'a, T: Iterator<Item=u8>>(self, data: T) -> SplitterVecs<T, Self> where Self: Sized

fn as_vecs<'a, T: Iterator<Item=u8>>(&'a self, data: T) -> SplitterVecs<T, &Self> where Self: Sized