Struct apache_avro::rabin::Rabin
source · [−]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 apache_avro::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
sourceimpl FixedOutput for Rabin
impl FixedOutput for Rabin
sourcefn finalize_into(self, out: &mut GenericArray<u8, Self::OutputSize>)
fn finalize_into(self, out: &mut GenericArray<u8, Self::OutputSize>)
Consume value and write result into provided array.
sourcefn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>
fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>
Retrieve result and consume the hasher instance.
sourceimpl FixedOutputReset for Rabin
impl FixedOutputReset for Rabin
sourcefn finalize_into_reset(&mut self, out: &mut Output<Self>)
fn finalize_into_reset(&mut self, out: &mut Output<Self>)
Write result into provided array and reset the hasher state.
sourcefn 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 state.
impl HashMarker for Rabin
Auto Trait Implementations
impl RefUnwindSafe for Rabin
impl Send for Rabin
impl Sync for Rabin
impl Unpin for Rabin
impl UnwindSafe for Rabin
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<D> Digest for D where
D: FixedOutput + Default + Update + HashMarker,
impl<D> Digest for D where
D: FixedOutput + Default + Update + HashMarker,
sourcefn new_with_prefix(data: impl AsRef<[u8]>) -> D where
D: Default,
fn new_with_prefix(data: impl AsRef<[u8]>) -> D where
D: Default,
Create new hasher instance which has processed the provided data.
sourcefn chain_update(self, data: impl AsRef<[u8]>) -> D
fn chain_update(self, data: impl AsRef<[u8]>) -> D
Process input data in a chained manner.
sourcefn finalize(self) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize>
fn finalize(self) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize>
Retrieve result and consume hasher instance.
sourcefn finalize_into(
self,
out: &mut GenericArray<u8, <D as OutputSizeUser>::OutputSize>
)
fn finalize_into(
self,
out: &mut GenericArray<u8, <D as OutputSizeUser>::OutputSize>
)
Write result into provided array and consume the hasher instance.
sourcefn finalize_reset(
&mut self
) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize> where
D: FixedOutputReset,
fn finalize_reset(
&mut self
) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize> where
D: FixedOutputReset,
Retrieve result and reset hasher instance.
sourcefn finalize_into_reset(
&mut self,
out: &mut GenericArray<u8, <D as OutputSizeUser>::OutputSize>
) where
D: FixedOutputReset,
fn finalize_into_reset(
&mut self,
out: &mut GenericArray<u8, <D as OutputSizeUser>::OutputSize>
) where
D: FixedOutputReset,
Write result into provided array and reset the hasher instance.
sourcefn output_size() -> usize
fn output_size() -> usize
Get output size of the hasher
sourceimpl<D> DynDigest for D where
D: 'static + Update + FixedOutputReset + Reset + Clone,
impl<D> DynDigest for D where
D: 'static + Update + FixedOutputReset + Reset + Clone,
sourcefn finalize_into(self, buf: &mut [u8]) -> Result<(), InvalidBufferSize>
fn finalize_into(self, buf: &mut [u8]) -> Result<(), InvalidBufferSize>
Write result into provided array and consume the hasher instance. Read more
sourcefn finalize_into_reset(
&mut self,
buf: &mut [u8]
) -> Result<(), InvalidBufferSize>
fn finalize_into_reset(
&mut self,
buf: &mut [u8]
) -> Result<(), InvalidBufferSize>
Write result into provided array and reset the hasher instance. Read more
sourcefn output_size(&self) -> usize
fn output_size(&self) -> usize
Get output size of the hasher