pub struct Hash { /* private fields */ }Expand description
A cryptographic hash value with its associated algorithm.
This type represents the result of applying a cryptographic hash function to some data. It stores both the resulting hash value and the algorithm used to create it.
Implementations§
Source§impl Hash
impl Hash
Sourcepub const fn new(algorithm: HashAlgorithm, bytes: ByteVec) -> Self
pub const fn new(algorithm: HashAlgorithm, bytes: ByteVec) -> Self
Creates a new hash value with the specified algorithm and bytes.
§Arguments
algorithm- The hash algorithm used to create this hashbytes- The raw hash value bytes
Sourcepub const fn get_algorithm(&self) -> HashAlgorithm
pub const fn get_algorithm(&self) -> HashAlgorithm
Returns the algorithm used to create this hash.
Sourcepub fn try_to_byte_vec(&self) -> Result<Arc<ByteVec>, SerialiseError>
pub fn try_to_byte_vec(&self) -> Result<Arc<ByteVec>, SerialiseError>
Converts this hash to a ByteVec suitable for encoding.
§Errors
Returns SerialiseError if the hash cannot be converted to bytes.
Sourcepub fn try_hash(
byte_vec: Arc<ByteVec>,
algorithm: HashAlgorithm,
) -> Result<Arc<Self>, SerialiseError>
pub fn try_hash( byte_vec: Arc<ByteVec>, algorithm: HashAlgorithm, ) -> Result<Arc<Self>, SerialiseError>
Computes a hash of the provided bytes using the given algorithm.
§Errors
Returns SerialiseError if hashing fails.
Trait Implementations§
Source§impl Decodable for Hash
impl Decodable for Hash
Source§fn try_decode(encoded_string: EncodedString) -> Result<Self, SerialiseError>where
Self: Sized,
fn try_decode(encoded_string: EncodedString) -> Result<Self, SerialiseError>where
Self: Sized,
Attempts to decode an encoded string into this type. Read more
Source§impl Ord for Hash
impl Ord for Hash
Source§impl PartialOrd for Hash
impl PartialOrd for Hash
Source§impl TryIntoByteVec for Hash
impl TryIntoByteVec for Hash
Source§fn try_into_byte_vec(value: Arc<Self>) -> Result<Arc<ByteVec>, SerialiseError>
fn try_into_byte_vec(value: Arc<Self>) -> Result<Arc<ByteVec>, SerialiseError>
Converts Self to a
ByteVec. Read moreimpl Eq for Hash
impl StructuralPartialEq for Hash
Auto Trait Implementations§
impl Freeze for Hash
impl RefUnwindSafe for Hash
impl Send for Hash
impl Sync for Hash
impl Unpin for Hash
impl UnsafeUnpin for Hash
impl UnwindSafe for Hash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more