pub struct ContentHash {
pub codec: u8,
pub digest: Vec<u8>,
}Expand description
Self-describing content address (multihash-style envelope).
Fields§
§codec: u8Hash-function identifier; 0x1e = BLAKE3-256, following the
multicodec table.
digest: Vec<u8>Raw digest bytes for codec.
Implementations§
Source§impl ContentHash
impl ContentHash
Sourcepub fn from_git_oid(hex: &str) -> Option<Self>
pub fn from_git_oid(hex: &str) -> Option<Self>
Wraps a git object id (hex) in the envelope: codec 0x11 for
SHA-1 (40 hex chars) or 0x12 for SHA-256 (64), per the
multicodec table. None for anything else. This is how git ref
updates enter the op log without pretending to be BLAKE3.
Sourcepub fn git_oid(&self) -> Option<String>
pub fn git_oid(&self) -> Option<String>
The git object id this envelope carries, or None if it is not a
git hash. The inverse of ContentHash::from_git_oid, for the
paths that have to hand an oid back to git itself.
Sourcepub fn from_hex(text: &str) -> Option<Self>
pub fn from_hex(text: &str) -> Option<Self>
Parses what ContentHash::to_hex produced. None for anything
else, including a bare digest with no codec prefix.
Its only caller is a lookup that reads a key id back out of a hex-keyed map and has to put it in a persisted record. That is also the reason it refuses an unprefixed digest rather than guessing a codec: inventing the byte that says which hash function this is would defeat the envelope (D6).
Trait Implementations§
Source§impl Clone for ContentHash
impl Clone for ContentHash
Source§fn clone(&self) -> ContentHash
fn clone(&self) -> ContentHash
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentHash
impl Debug for ContentHash
Source§impl<'de> Deserialize<'de> for ContentHash
impl<'de> Deserialize<'de> for ContentHash
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 Hash for ContentHash
impl Hash for ContentHash
Source§impl PartialEq for ContentHash
impl PartialEq for ContentHash
Source§fn eq(&self, other: &ContentHash) -> bool
fn eq(&self, other: &ContentHash) -> bool
self and other values to be equal, and is used by ==.