Trait den::RollingHasher

source ·
pub trait RollingHasher {
    type Hash;

    // Required methods
    fn new(block_size: usize) -> Self;
    fn reset(&mut self, block_size: usize);
    fn update(&mut self, block: &[u8], block_size: usize);
    fn rotate(&mut self, old: u8, new: u8, block_size: usize);
    fn value(&self) -> Self::Hash;
}
Expand description

Used to make RollingHash generic.

This is implemented by the Adler32 algorithm and both variants of the cyclic poly 32 algorithm. The implementation of cyclic poly 23 is in a Box due to the large size of the struct (1KiB and 2KiB for the 32- and 64-bit implementations respectively).

Required Associated Types§

source

type Hash

The hash returned from this hasher.

Required Methods§

source

fn new(block_size: usize) -> Self

Create a new hasher.

source

fn reset(&mut self, block_size: usize)

Reset the inner state. If the struct provides no such functionality, consider overriding the current value with a new instance.

source

fn update(&mut self, block: &[u8], block_size: usize)

Write the block to the hasher.

source

fn rotate(&mut self, old: u8, new: u8, block_size: usize)

Remove old and add new.

source

fn value(&self) -> Self::Hash

Get the current internal hash.

Implementations on Foreign Types§

source§

impl RollingHasher for Box<CyclicPoly64>

§

type Hash = u64

source§

fn new(block_size: usize) -> Self

source§

fn reset(&mut self, _: usize)

source§

fn update(&mut self, block: &[u8], _: usize)

source§

fn rotate(&mut self, old: u8, new: u8, _: usize)

source§

fn value(&self) -> Self::Hash

source§

impl RollingHasher for RollingAdler32

§

type Hash = u32

source§

fn new(_: usize) -> Self

source§

fn reset(&mut self, _: usize)

source§

fn update(&mut self, block: &[u8], _: usize)

source§

fn rotate(&mut self, old: u8, new: u8, block_size: usize)

source§

fn value(&self) -> Self::Hash

source§

impl RollingHasher for Box<CyclicPoly32>

§

type Hash = u32

source§

fn new(block_size: usize) -> Self

source§

fn reset(&mut self, _: usize)

source§

fn update(&mut self, block: &[u8], _: usize)

source§

fn rotate(&mut self, old: u8, new: u8, _: usize)

source§

fn value(&self) -> Self::Hash

Implementors§