pub trait Hashing<const LENGTH: usize>: Clone + Sized {
// Required methods
fn hash(data: &[u8]) -> Self;
fn as_bytes(&self) -> &[u8] ⓘ;
fn from_bytes(bytes: &[u8]) -> StacksResult<Self>;
// Provided methods
fn new(value: impl AsRef<[u8]>) -> Self { ... }
fn zeroes() -> Self { ... }
fn checksum(&self) -> [u8; 4] { ... }
fn from_hex(data: impl AsRef<str>) -> StacksResult<Self> { ... }
fn to_hex(&self) -> String { ... }
}
Expand description
Hashing trait
Required Methods§
Sourcefn from_bytes(bytes: &[u8]) -> StacksResult<Self>
fn from_bytes(bytes: &[u8]) -> StacksResult<Self>
Attempt to create a hash from the given bytes
Provided Methods§
Sourcefn from_hex(data: impl AsRef<str>) -> StacksResult<Self>
fn from_hex(data: impl AsRef<str>) -> StacksResult<Self>
Attempt to create a hash from the given hex bytes
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.