pub struct Rabin { /* private fields */ }
Expand description
Implementation of the Rabin fingerprint algorithm using the Digest trait as described in schema_fingerprints.
The digest is returned as the 8-byte little-endian encoding of the Rabin hash. This is what is used for avro single object encoding
use avro_rs::rabin::Rabin;
use digest::Digest;
use hex_literal::hex;
// create the Rabin hasher
let mut hasher = Rabin::new();
// add the data
hasher.update(b"hello world");
// read hash digest and consume hasher
let result = hasher.finalize();
assert_eq!(result[..], hex!("60335ba6d0415528"));
To convert the digest to the commonly used 64-bit integer value, you can use the byteorder crate:
use byteorder::{ByteOrder, LittleEndian};
let i = LittleEndian::read_i64(&result.to_vec());
assert_eq!(i, 2906301498937520992)
Trait Implementations§
Source§impl FixedOutput for Rabin
impl FixedOutput for Rabin
Source§type OutputSize = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>
type OutputSize = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>
Output size for fixed output digest
Source§fn finalize_into(self, out: &mut GenericArray<u8, Self::OutputSize>)
fn finalize_into(self, out: &mut GenericArray<u8, Self::OutputSize>)
Write result into provided array and consume the hasher instance.
Source§fn finalize_into_reset(&mut self, out: &mut GenericArray<u8, Self::OutputSize>)
fn finalize_into_reset(&mut self, out: &mut GenericArray<u8, Self::OutputSize>)
Write result into provided array and reset the hasher instance.
Source§fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>where
Self: Sized,
fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>where
Self: Sized,
Retrieve result and consume the hasher instance.
Source§fn finalize_fixed_reset(&mut self) -> GenericArray<u8, Self::OutputSize>
fn finalize_fixed_reset(&mut self) -> GenericArray<u8, Self::OutputSize>
Retrieve result and reset the hasher instance.
Auto Trait Implementations§
impl Freeze for Rabin
impl RefUnwindSafe for Rabin
impl Send for Rabin
impl Sync for Rabin
impl Unpin for Rabin
impl UnwindSafe for Rabin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<D> Digest for D
impl<D> Digest for D
Source§type OutputSize = <D as FixedOutput>::OutputSize
type OutputSize = <D as FixedOutput>::OutputSize
Output size for
Digest
Source§fn update(&mut self, data: impl AsRef<[u8]>)
fn update(&mut self, data: impl AsRef<[u8]>)
Digest data, updating the internal state. Read more
Source§fn finalize(self) -> GenericArray<u8, <D as Digest>::OutputSize>
fn finalize(self) -> GenericArray<u8, <D as Digest>::OutputSize>
Retrieve result and consume hasher instance.
Source§fn finalize_reset(&mut self) -> GenericArray<u8, <D as Digest>::OutputSize>
fn finalize_reset(&mut self) -> GenericArray<u8, <D as Digest>::OutputSize>
Retrieve result and reset hasher instance. Read more
Source§fn output_size() -> usize
fn output_size() -> usize
Get output size of the hasher
Source§fn digest(data: &[u8]) -> GenericArray<u8, <D as Digest>::OutputSize>
fn digest(data: &[u8]) -> GenericArray<u8, <D as Digest>::OutputSize>
Convenience function to compute hash of the
data
. It will handle
hasher creation, data feeding and finalization. Read moreSource§impl<D> DynDigest for D
impl<D> DynDigest for D
Source§fn finalize_reset(&mut self) -> Box<[u8]>
fn finalize_reset(&mut self) -> Box<[u8]>
Retrieve result and reset hasher instance
Source§fn output_size(&self) -> usize
fn output_size(&self) -> usize
Get output size of the hasher