pub struct Hash { /* private fields */ }Expand description
The hash of some content, together with the algorithm that produced it.
Its text form is the algorithm’s name, a colon and the digest in lowercase hexadecimal,
such as blake3:af1349b9…. In CBOR, it is a byte string holding a multihash.
Implementations§
Source§impl Hash
impl Hash
Sourcepub fn algorithm(&self) -> HashAlgorithm
pub fn algorithm(&self) -> HashAlgorithm
The algorithm that produced the hash.
Sourcepub fn to_multihash(&self) -> Vec<u8> ⓘ
pub fn to_multihash(&self) -> Vec<u8> ⓘ
The binary form: a multihash, that is the algorithm’s code and the digest’s length as unsigned varints, followed by the digest.
Sourcepub fn from_multihash(bytes: &[u8]) -> Result<Self, ParseHashError>
pub fn from_multihash(bytes: &[u8]) -> Result<Self, ParseHashError>
Reads the binary form.
§Errors
Returns an error if bytes is not a multihash, if its algorithm is unknown, or if
the digest does not have the algorithm’s length.
Trait Implementations§
impl Copy for Hash
impl Eq for Hash
Source§impl Ord for Hash
impl Ord for Hash
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Hash
impl PartialOrd for Hash
impl StructuralPartialEq for Hash
Auto Trait Implementations§
impl Forget for Hash
impl Freeze for Hash
impl Move 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