pub struct Hash<K: HashKind>([u8; 32], PhantomData<K>);Expand description
The kind is a compile-time tag and must not reach the wire, so only the digest is encoded — as hex text in a format a human reads (the log, the projection, the clipboard), where a 32-element array of numbers would be unreadable and ungreppable, and as the bare bytes in a binary one.
Tuple Fields§
§0: [u8; 32]§1: PhantomData<K>Implementations§
Source§impl<K: HashKind> Hash<K>
impl<K: HashKind> Hash<K>
Sourcepub fn of(bytes: &[u8]) -> Self
pub fn of(bytes: &[u8]) -> Self
The hash of a byte string in one call — what content addressing asks for everywhere the payload is already in hand.
Trait Implementations§
Source§impl<'de, K: HashKind> Deserialize<'de> for Hash<K>
impl<'de, K: HashKind> Deserialize<'de> for Hash<K>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K: Ord + HashKind> Ord for Hash<K>
impl<K: Ord + HashKind> Ord for Hash<K>
Source§impl<K: PartialOrd + HashKind> PartialOrd for Hash<K>
impl<K: PartialOrd + HashKind> PartialOrd for Hash<K>
impl<K: Copy + HashKind> Copy for Hash<K>
impl<K: Eq + HashKind> Eq for Hash<K>
impl<K: HashKind> StructuralPartialEq for Hash<K>
Auto Trait Implementations§
impl<K> Freeze for Hash<K>
impl<K> RefUnwindSafe for Hash<K>where
K: RefUnwindSafe,
impl<K> Send for Hash<K>where
K: Send,
impl<K> Sync for Hash<K>where
K: Sync,
impl<K> Unpin for Hash<K>where
K: Unpin,
impl<K> UnsafeUnpin for Hash<K>
impl<K> UnwindSafe for Hash<K>where
K: UnwindSafe,
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