[][src]Trait rollsum::Engine

pub trait Engine {
    type Digest;
    fn roll_byte(&mut self, byte: u8);
fn digest(&self) -> Self::Digest;
fn reset(&mut self); 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
, { ... } }

Rolling sum engine trait

Associated Types

type Digest

Loading content...

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

Loading content...

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

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 whole buf.
Loading content...

Implementors

impl Engine for Bup[src]

type Digest = u32

impl Engine for Gear[src]

type Digest = u64

Loading content...