pub struct Hash(/* private fields */);Expand description
A 32-byte hash value.
This is the fundamental building block for commitments, right IDs, seal references, and all cryptographic operations in CSV.
Implementations§
Source§impl Hash
impl Hash
Sourcepub const fn new(bytes: [u8; 32]) -> Self
pub const fn new(bytes: [u8; 32]) -> Self
Creates a new Hash from exactly 32 bytes.
§Panics
This method does not panic — it accepts any [u8; 32]. For fallible
construction from a slice, use Hash::try_from.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8; 32]
pub fn as_bytes_mut(&mut self) -> &mut [u8; 32]
Returns a mutable reference to the underlying 32-byte array.
Sourcepub fn into_inner(self) -> [u8; 32]
pub fn into_inner(self) -> [u8; 32]
Consumes the hash and returns the inner byte array.
Sourcepub fn to_vec(&self) -> Vec<u8> ⓘ
pub fn to_vec(&self) -> Vec<u8> ⓘ
Returns a new Vec<u8> containing the hash bytes.
This allocates. For a borrowed slice, use Self::as_slice.
Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Returns the hash as a lowercase hex string without the 0x prefix.
The returned string is always 64 characters long.
Sourcepub fn from_hex(s: &str) -> Result<Self, HashParseError>
pub fn from_hex(s: &str) -> Result<Self, HashParseError>
Parses a Hash from a hex string.
The input may optionally start with 0x or 0X. The remaining
characters must be valid hex digits representing exactly 32 bytes.
§Errors
Returns HashParseError if the input is not valid hex or does not
represent exactly 32 bytes.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Hash
impl<'de> Deserialize<'de> for Hash
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Hash
impl Ord for Hash
Source§impl PartialOrd for Hash
impl PartialOrd for Hash
impl Copy for Hash
impl 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> Base32Len for T
impl<T> Base32Len for T
Source§fn base32_len(&self) -> usize
fn base32_len(&self) -> usize
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
Source§impl<T> CheckBase32<Vec<u5>> for T
impl<T> CheckBase32<Vec<u5>> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToBase32 for T
impl<T> ToBase32 for T
Source§fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>where
W: WriteBase32,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)