Trait lrs::hash::Hasher

Objects that can hash other objects.

Syntax

trait Hasher {
    type Digest: Into<u64>;
    type Seed: Default;

    /* Required methods */
    fn digest(&self) -> <Self as Hasher>::Digest
    fn hash_bytes<S>(val: &[u8], seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn new<S>(seed: S) -> Self
        where S: Into<<Self as Hasher>::Seed>,
    fn reset<S>(&mut self, seed: S) -> ()
        where S: Into<<Self as Hasher>::Seed>,
    fn write_bytes(&mut self, val: &[u8]) -> ()

    /* Provided methods */
    fn hash<T, S>(val: &T, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
              T: Hash + ?Sized,
    fn hash_i16<S>(val: i16, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_i32<S>(val: i32, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_i64<S>(val: i64, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_i8<S>(val: i8, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_isize<S>(val: isize, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_u16<S>(val: u16, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_u32<S>(val: u32, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_u64<S>(val: u64, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_u8<S>(val: u8, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn hash_usize<S>(val: usize, seed: S) -> <Self as Hasher>::Digest
        where S: Into<<Self as Hasher>::Seed>,
    fn write_i16(&mut self, val: i16) -> ()
    fn write_i32(&mut self, val: i32) -> ()
    fn write_i64(&mut self, val: i64) -> ()
    fn write_i8(&mut self, val: i8) -> ()
    fn write_isize(&mut self, val: isize) -> ()
    fn write_u16(&mut self, val: u16) -> ()
    fn write_u32(&mut self, val: u32) -> ()
    fn write_u64(&mut self, val: u64) -> ()
    fn write_u8(&mut self, val: u8) -> ()
    fn write_usize(&mut self, val: usize) -> ()
}

Associated types

NameDescription
Digest

The output of the hash operation.

Seed

The type used to seed a hash operation.

Methods

ReceiverNameDescription
&selfdigest

Returns the digest of the hasher.

hash

Hashes a value with this hasher.

hash_bytes

Hashes a sequence of bytes.

hash_i16

Hashes an i16.

hash_i32

Hashes an i32.

hash_i64

Hashes an i64.

hash_i8

Hashes an i8.

hash_isize

Hashes an usize.

hash_u16

Hashes a u16.

hash_u32

Hashes a u32.

hash_u64

Hashes a u64.

hash_u8

Hashes a u8.

hash_usize

Hashes a usize.

new

Creates a new hasher for stateful hashing.

&mut selfreset

Resets the hasher to it's initial state with a new seed.

&mut selfwrite_bytes

Adds a slice of bytes to the hasher.

&mut selfwrite_i16

Adds an i16 to the hasher.

&mut selfwrite_i32

Adds an i32 to the hasher.

&mut selfwrite_i64

Adds an i64 to the hasher.

&mut selfwrite_i8

Adds an i8 to the hasher.

&mut selfwrite_isize

Adds an isize to the hasher.

&mut selfwrite_u16

Adds a u16 to the hasher.

&mut selfwrite_u32

Adds a u32 to the hasher.

&mut selfwrite_u64

Adds a u64 to the hasher.

&mut selfwrite_u8

Adds a u8 to the hasher.

&mut selfwrite_usize

Adds a usize to the hasher.