Skip to main content

DynHasher

Trait DynHasher 

Source
pub trait DynHasher: Send {
    // Required methods
    fn update(&mut self, data: &[u8]);
    fn finalize(&mut self) -> Vec<u8> ;

    // Provided method
    fn update_mmap_rayon(&mut self, _path: &Path) -> Result<(), Error> { ... }
}
Expand description

Trait to allow for dynamic dispatch of different hashers. This is necessary because the Digest trait does not support dynamic dispatch, and we want to be able to use different hash algorithms with the same interface.

Required Methods§

Source

fn update(&mut self, data: &[u8])

Update the hasher with the given data

Source

fn finalize(&mut self) -> Vec<u8>

Finalize the hasher and return the resulting hash as a byte vector

Provided Methods§

Source

fn update_mmap_rayon(&mut self, _path: &Path) -> Result<(), Error>

Only supported for blake3 with the mmap and rayon features enabled. All other hashers return an error by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§