pub trait HashInto {
    // Required method
    fn hash_into(self, hash: &mut impl Digest);
}
Expand description

Anything that can be hashed.

The implementations of this trait decide how the type will be converted into bytes so that it can be included in the hash.

§Example

use digest::Digest;
use secp256kfun::hash::{HashAdd, HashInto};
#[derive(Clone, Copy)]
struct CryptoData([u8; 42]);

impl HashInto for CryptoData {
    fn hash_into(self, hash: &mut impl digest::Digest) {
        hash.update(&self.0[..])
    }
}

let cryptodata = CryptoData([42u8; 42]);
let hash = sha2::Sha256::default().add(cryptodata).finalize();

Required Methods§

source

fn hash_into(self, hash: &mut impl Digest)

Asks the item to convert itself to bytes and add itself to hash.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl HashInto for &str

source§

fn hash_into(self, hash: &mut impl Digest)

source§

impl HashInto for u8

source§

fn hash_into(self, hash: &mut impl Digest)

source§

impl<'a, T> HashInto for &'a [T]
where &'a T: HashInto,

source§

fn hash_into(self, hash: &mut impl Digest)

source§

impl<'a, T: HashInto + Clone> HashInto for &'a T

source§

fn hash_into(self, hash: &mut impl Digest)

source§

impl<T: HashInto, const N: usize> HashInto for [T; N]

source§

fn hash_into(self, hash: &mut impl Digest)

Implementors§

source§

impl<'a, S> HashInto for Slice<'a, S>

source§

impl<S> HashInto for Point<EvenY, S, NonZero>

source§

impl<S, Z> HashInto for Point<Normal, S, Z>

source§

impl<S, Z> HashInto for Scalar<S, Z>