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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Consume value and write result into provided array.

Retrieve result and consume the hasher instance.

Write result into provided array and reset the hasher state.

Retrieve result and reset the hasher state.

Size of the output in bytes.

Return output size in bytes.

Reset state to its initial value.

Update state using the provided data.

Digest input data in a chained manner.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Create new hasher instance.

Create new hasher instance which has processed the provided data.

Process data, updating the internal state.

Process input data in a chained manner.

Retrieve result and consume hasher instance.

Write result into provided array and consume the hasher instance.

Retrieve result and reset hasher instance.

Write result into provided array and reset the hasher instance.

Reset hasher instance to its initial state.

Get output size of the hasher

Compute hash of data.

Digest input data. Read more

Write result into provided array and consume the hasher instance. Read more

Write result into provided array and reset the hasher instance. Read more

Reset hasher instance to its initial state.

Get output size of the hasher

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.