pub trait Hash:
Copy
+ Clone
+ PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Hash
+ Debug
+ Display
+ LowerHex
+ AsRef<[u8]> {
type Bytes: FromHex + Copy + IsByteArray;
const LEN: usize = <Self::Bytes>::LEN;
const DISPLAY_BACKWARD: bool = false;
// Required methods
fn from_byte_array(bytes: Self::Bytes) -> Self;
fn from_slice(sl: &[u8]) -> Result<Self, FromSliceError>;
fn to_byte_array(self) -> Self::Bytes;
fn as_byte_array(&self) -> &Self::Bytes;
}
Expand description
Trait which applies to hashes of all types.
Provided Associated Constants§
Sourceconst DISPLAY_BACKWARD: bool = false
const DISPLAY_BACKWARD: bool = false
Flag indicating whether user-visible serializations of this hash should be backward.
For some reason Satoshi decided this should be true for Sha256dHash
, so here we are.
Required Associated Types§
Sourcetype Bytes: FromHex + Copy + IsByteArray
type Bytes: FromHex + Copy + IsByteArray
The byte array that represents the hash internally.
Required Methods§
Sourcefn from_byte_array(bytes: Self::Bytes) -> Self
fn from_byte_array(bytes: Self::Bytes) -> Self
Constructs a hash from the underlying byte array.
Sourcefn from_slice(sl: &[u8]) -> Result<Self, FromSliceError>
👎Deprecated since 0.15.0: use from_byte_array
instead
fn from_slice(sl: &[u8]) -> Result<Self, FromSliceError>
from_byte_array
insteadCopies a byte slice into a hash object.
Sourcefn to_byte_array(self) -> Self::Bytes
fn to_byte_array(self) -> Self::Bytes
Returns the underlying byte array.
Sourcefn as_byte_array(&self) -> &Self::Bytes
fn as_byte_array(&self) -> &Self::Bytes
Returns a reference to the underlying byte array.
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.