bitcoin_hashes

Trait Hash

Source
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§

Source

const LEN: usize = <Self::Bytes>::LEN

Length of the hash, in bytes.

Source

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§

Source

type Bytes: FromHex + Copy + IsByteArray

The byte array that represents the hash internally.

Required Methods§

Source

fn from_byte_array(bytes: Self::Bytes) -> Self

Constructs a hash from the underlying byte array.

Source

fn from_slice(sl: &[u8]) -> Result<Self, FromSliceError>

👎Deprecated since 0.15.0: use from_byte_array instead

Copies a byte slice into a hash object.

Source

fn to_byte_array(self) -> Self::Bytes

Returns the underlying byte array.

Source

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.

Implementors§

Source§

impl Hash for bitcoin_hashes::Hash160

Source§

impl Hash for bitcoin_hashes::Ripemd160

Source§

impl Hash for bitcoin_hashes::Sha1

Source§

impl Hash for bitcoin_hashes::Sha256

Source§

impl Hash for bitcoin_hashes::Sha256d

Source§

impl Hash for bitcoin_hashes::Sha384

Source§

impl Hash for bitcoin_hashes::Sha512

Source§

impl Hash for bitcoin_hashes::Sha512_256

Source§

impl Hash for bitcoin_hashes::Siphash24

Source§

impl<T: Tag> Hash for bitcoin_hashes::sha256t::Hash<T>

Source§

impl<T: GeneralHash> Hash for Hmac<T>

Source§

type Bytes = <T as Hash>::Bytes