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).
Trait Implementations§
impl Copy for HashAlgo
impl Eq for HashAlgo
Source§impl Ord for HashAlgo
impl Ord for HashAlgo
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for HashAlgo
impl PartialOrd for HashAlgo
impl StructuralPartialEq for HashAlgo
Auto Trait Implementations§
impl Freeze for HashAlgo
impl RefUnwindSafe for HashAlgo
impl Send for HashAlgo
impl Sync for HashAlgo
impl Unpin for HashAlgo
impl UnsafeUnpin for HashAlgo
impl UnwindSafe for HashAlgo
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.