aum_core/hash.rs
1use thiserror::Error;
2pub trait Hash {
3 fn from_bytes(bytes: &[u8]) -> Result<Self, HashError>
4 where
5 Self: Sized;
6 fn to_bytes(&self) -> Vec<u8>;
7 fn from_hex(hex: &str) -> Result<Self, HashError>
8 where
9 Self: Sized;
10 fn to_hex(&self) -> String;
11}
12
13#[derive(Debug, Error)]
14pub enum HashError {
15 #[error("Invalid byte representation")]
16 InvalidBytes,
17 #[error("Invalid hexadecimal representation")]
18 InvalidHex,
19 #[error("Hashing error")]
20 HashingError,
21}