pub struct Hash(pub String);Expand description
A content hash. The underlying algorithm depends on the backend that produced it: SQLite/Postgres backends produce BLAKE3; the git backend produces git OIDs (SHA-1 today, SHA-256 in repos using the sha256 object format).
Tuple Fields§
§0: StringImplementations§
Source§impl Hash
impl Hash
Sourcepub fn from_hex(hex: &str) -> Result<Self>
pub fn from_hex(hex: &str) -> Result<Self>
Create a Hash from a hex string. Accepts 40 hex chars (git SHA-1) or 64 hex chars
(BLAKE3 or git SHA-256), lowercase only — the canonical form every
producer (BLAKE3 to_hex, git OIDs) emits, and the form hash preimages
embed, so an uppercase alias of a stored hash is never valid.
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>,
Deserialization is a trust boundary — wire payloads and stored JSON
land here — so it enforces the same lowercase-hex shape as
Hash::from_hex. Without it, arbitrary text (including the \t/\n
bytes the canonical tree and commit preimages use as separators) could
be injected into hash-position fields.
impl Eq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more