Trait bitcoin_hashes::Hash
source · pub trait Hash: Copy + Clone + PartialEq + Eq + Debug + Display + LowerHex + Index<RangeFull, Output = [u8]> + Index<RangeFrom<usize>, Output = [u8]> + Index<RangeTo<usize>, Output = [u8]> + Index<Range<usize>, Output = [u8]> + Index<usize, Output = u8> + ToHex {
type Engine: HashEngine;
fn engine() -> Self::Engine;
fn from_engine(e: Self::Engine) -> Self;
fn len() -> usize;
fn block_size() -> usize;
fn from_slice(sl: &[u8]) -> Result<Self, Error>;
fn hash(data: &[u8]) -> Self { ... }
fn display_backward() -> bool { ... }
}
Expand description
Trait which applies to hashes of all types
Required Associated Types
sourcetype Engine: HashEngine
type Engine: HashEngine
A hashing engine which bytes can be serialized into. It is expected
to implement the io::Write
trait, and to never return errors under
any conditions.
Required Methods
sourcefn from_engine(e: Self::Engine) -> Self
fn from_engine(e: Self::Engine) -> Self
Produce a hash from the current state of a given engine
sourcefn block_size() -> usize
fn block_size() -> usize
Length of the hash’s internal block size, in bytes
sourcefn from_slice(sl: &[u8]) -> Result<Self, Error>
fn from_slice(sl: &[u8]) -> Result<Self, Error>
Copies a byte slice into a hash object
Provided Methods
sourcefn display_backward() -> bool
fn display_backward() -> bool
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.