nintypes 0.2.11

Nintondo shared types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use primitive_types::H256;
use std::str::FromStr;

use crate::common::hash::Hash256;
pub fn sha256_hex(data: &[u8]) -> String {
    sha256::digest(data)
}

pub trait IntoHash256 {
    fn hash_256(&self) -> Hash256;
}

impl<T: core::convert::AsRef<[u8]>> IntoHash256 for T {
    fn hash_256(&self) -> Hash256 {
        H256::from_str(&sha256_hex(self.as_ref())).unwrap().into()
    }
}