pub enum HashAlgo {
Sha1,
Sha256,
}Expand description
A Git hash algorithm.
Git supports two object-id hash functions: the historical SHA-1 (20-byte
digests, 40 hex chars) and the newer SHA-256 (32-byte digests, 64 hex
chars). A repository’s algorithm is recorded in extensions.objectformat.
Variants§
Implementations§
Source§impl HashAlgo
impl HashAlgo
Sourcepub fn checksum_hasher(self) -> ChecksumHasher ⓘ
pub fn checksum_hasher(self) -> ChecksumHasher ⓘ
Return a fresh incremental checksum hasher for this algorithm.
Sourcepub fn checksum_digest(self, data: &[u8]) -> Vec<u8> ⓘ
pub fn checksum_digest(self, data: &[u8]) -> Vec<u8> ⓘ
Hash a byte slice with no Git object header and return a file checksum.
Sourcepub fn hasher(self) -> ObjectHasher ⓘ
pub fn hasher(self) -> ObjectHasher ⓘ
Return a fresh incremental hasher for this algorithm.
Sourcepub fn digest(self, data: &[u8]) -> Result<ObjectId>
pub fn digest(self, data: &[u8]) -> Result<ObjectId>
Hash a byte slice with no Git object header.
§Errors
Returns Error::HashCollision when sha1dc detects a chosen-prefix collision.
Sourcepub fn hash_object(self, kind: ObjectKind, data: &[u8]) -> Result<ObjectId>
pub fn hash_object(self, kind: ObjectKind, data: &[u8]) -> Result<ObjectId>
Hash canonical Git store bytes for kind and data.
§Errors
Returns Error::HashCollision when sha1dc detects a chosen-prefix collision.
Source§impl HashAlgo
impl HashAlgo
Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Always false — every hash algorithm has a non-zero digest length.
Sourcepub const fn hex_len(self) -> usize
pub const fn hex_len(self) -> usize
The hex-encoded digest length (40 for SHA-1, 64 for SHA-256).
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The lowercase name as written in extensions.objectformat.
Sourcepub const fn oid_version(self) -> u8
pub const fn oid_version(self) -> u8
The oid_version byte used in .idx/multi-pack-index headers
(SHA-1 → 1, SHA-256 → 2).