[−][src]Trait rollsum::Engine
Rolling sum engine trait
Associated Types
type Digest
Required methods
fn roll_byte(&mut self, byte: u8)
Roll over one byte
fn digest(&self) -> Self::Digest
Return current rolling sum digest
fn reset(&mut self)
Resets the internal state
Provided methods
fn roll(&mut self, buf: &[u8])
Roll over a slice of bytes
fn find_chunk_edge_cond<F>(
&mut self,
buf: &[u8],
cond: F
) -> Option<(usize, Self::Digest)> where
F: Fn(&Self) -> bool,
&mut self,
buf: &[u8],
cond: F
) -> Option<(usize, Self::Digest)> where
F: Fn(&Self) -> bool,
Find the end of the chunk.
Feed engine bytes from buf
and stop when chunk split was found.
Use cond
function as chunk split condition.
When edge is find, state of self
is reset, using reset()
method.
Returns:
- None - no chunk split was found
- Some - offset of the first unconsumed byte of
buf
and the digest of the whole chunk.offset
== buf.len() if the chunk ended right after the wholebuf
.