pub struct Hash(/* private fields */);
Expand description
Output of the SHA256 hash function.
Implementations§
Source§impl Hash
impl Hash
Sourcepub const fn from_byte_array(bytes: [u8; 32]) -> Hash
pub const fn from_byte_array(bytes: [u8; 32]) -> Hash
Constructs a new hash from the underlying byte array.
Sourcepub fn from_bytes_ref(bytes: &[u8; 32]) -> &Hash
pub fn from_bytes_ref(bytes: &[u8; 32]) -> &Hash
Zero cost conversion between a fixed length byte array shared reference and a shared reference to this Hash type.
Sourcepub fn from_bytes_mut(bytes: &mut [u8; 32]) -> &mut Hash
pub fn from_bytes_mut(bytes: &mut [u8; 32]) -> &mut Hash
Zero cost conversion between a fixed length byte array exclusive reference and an exclusive reference to this Hash type.
Sourcepub fn from_slice(sl: &[u8]) -> Result<Hash, FromSliceError>
pub fn from_slice(sl: &[u8]) -> Result<Hash, FromSliceError>
Copies a byte slice into a hash object.
Sourcepub const fn to_byte_array(self) -> [u8; 32]
pub const fn to_byte_array(self) -> [u8; 32]
Returns the underlying byte array.
Sourcepub const fn as_byte_array(&self) -> &[u8; 32]
pub const fn as_byte_array(&self) -> &[u8; 32]
Returns a reference to the underlying byte array.
Source§impl Hash
impl Hash
Sourcepub fn from_engine(e: HashEngine) -> Hash
pub fn from_engine(e: HashEngine) -> Hash
Produces a hash from the current state of a given engine.
Sourcepub fn engine() -> HashEngine
pub fn engine() -> HashEngine
Constructs a new engine.
Sourcepub fn hash_byte_chunks<B, I>(byte_slices: I) -> Hash
pub fn hash_byte_chunks<B, I>(byte_slices: I) -> Hash
Hashes all the byte slices retrieved from the iterator together.
Source§impl Hash
impl Hash
Sourcepub fn hash_again(&self) -> Hash
pub fn hash_again(&self) -> Hash
Iterate the sha256 algorithm to turn a sha256 hash into a sha256d hash
Sourcepub const fn const_hash(bytes: &[u8]) -> Hash
👎Deprecated since 0.15.0: use Self::hash_unoptimized
instead
pub const fn const_hash(bytes: &[u8]) -> Hash
Self::hash_unoptimized
insteadComputes hash from bytes
in const
context.
Warning: this function is inefficient. It should be only used in const
context.
Sourcepub const fn hash_unoptimized(bytes: &[u8]) -> Hash
pub const fn hash_unoptimized(bytes: &[u8]) -> Hash
Computes hash from bytes
in const
context.
Warning: this function is inefficient. It should be only used in const
context.
Trait Implementations§
Source§impl GeneralHash for Hash
impl GeneralHash for Hash
Source§type Engine = HashEngine
type Engine = HashEngine
io::Write
trait, and to never return errors under
any conditions.Source§fn from_engine(e: HashEngine) -> Hash
fn from_engine(e: HashEngine) -> Hash
Source§fn hash_byte_chunks<B, I>(byte_slices: I) -> Self
fn hash_byte_chunks<B, I>(byte_slices: I) -> Self
Source§impl Hash for Hash
impl Hash for Hash
Source§const DISPLAY_BACKWARD: bool = false
const DISPLAY_BACKWARD: bool = false
Source§fn from_byte_array(bytes: <Hash as Hash>::Bytes) -> Hash
fn from_byte_array(bytes: <Hash as Hash>::Bytes) -> Hash
Source§fn from_slice(sl: &[u8]) -> Result<Hash, FromSliceError>
fn from_slice(sl: &[u8]) -> Result<Hash, FromSliceError>
from_byte_array
instead