pub trait Engine {
type Digest;
// Required methods
fn roll_byte(&mut self, byte: u8);
fn digest(&self) -> Self::Digest;
fn reset(&mut self);
// Provided methods
fn roll(&mut self, buf: &[u8]) { ... }
fn find_chunk_edge_cond<F>(
&mut self,
buf: &[u8],
cond: F,
) -> Option<(usize, Self::Digest)>
where F: Fn(&Self) -> bool { ... }
}
Expand description
Rolling sum engine trait
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn find_chunk_edge_cond<F>(
&mut self,
buf: &[u8],
cond: F,
) -> Option<(usize, Self::Digest)>
fn find_chunk_edge_cond<F>( &mut self, buf: &[u8], cond: F, ) -> Option<(usize, Self::Digest)>
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
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.