55//! Otherwise, a minimal yet performant implementation is used instead for a decent trade-off between compile times and run-time performance.
66#[ cfg( all( feature = "rustsha1" , not( feature = "fast-sha1" ) ) ) ]
77mod _impl {
8- use super :: Sha1Digest ;
8+ use super :: Digest ;
99
1010 /// A implementation of the Sha1 hash, which can be used once.
1111 #[ derive( Default , Clone ) ]
@@ -17,22 +17,20 @@ mod _impl {
1717 self . 0 . update ( bytes) ;
1818 }
1919 /// Finalize the hash and produce a digest.
20- pub fn digest ( self ) -> Sha1Digest {
20+ pub fn digest ( self ) -> Digest {
2121 self . 0 . digest ( ) . bytes ( )
2222 }
2323 }
2424}
2525
26- /// A 20 bytes digest produced by a [`Sha1 `] hash implementation.
26+ /// A hash- digest produced by a [`Hasher `] hash implementation.
2727#[ cfg( any( feature = "fast-sha1" , feature = "rustsha1" ) ) ]
28- pub type Sha1Digest = [ u8 ; 20 ] ;
28+ pub type Digest = [ u8 ; 20 ] ;
2929
3030#[ cfg( feature = "fast-sha1" ) ]
3131mod _impl {
3232 use sha1:: Digest ;
3333
34- use super :: Sha1Digest ;
35-
3634 /// A implementation of the Sha1 hash, which can be used once.
3735 #[ derive( Default , Clone ) ]
3836 pub struct Sha1 ( sha1:: Sha1 ) ;
@@ -43,14 +41,14 @@ mod _impl {
4341 self . 0 . update ( bytes) ;
4442 }
4543 /// Finalize the hash and produce a digest.
46- pub fn digest ( self ) -> Sha1Digest {
44+ pub fn digest ( self ) -> super :: Digest {
4745 self . 0 . finalize ( ) . into ( )
4846 }
4947 }
5048}
5149
5250#[ cfg( any( feature = "rustsha1" , feature = "fast-sha1" ) ) ]
53- pub use _impl:: Sha1 ;
51+ pub use _impl:: Sha1 as Hasher ;
5452
5553/// Compute a CRC32 hash from the given `bytes`, returning the CRC32 hash.
5654///
@@ -76,9 +74,9 @@ pub fn crc32(bytes: &[u8]) -> u32 {
7674
7775/// Produce a hasher suitable for the given kind of hash.
7876#[ cfg( any( feature = "rustsha1" , feature = "fast-sha1" ) ) ]
79- pub fn hasher ( kind : gix_hash:: Kind ) -> Sha1 {
77+ pub fn hasher ( kind : gix_hash:: Kind ) -> Hasher {
8078 match kind {
81- gix_hash:: Kind :: Sha1 => Sha1 :: default ( ) ,
79+ gix_hash:: Kind :: Sha1 => Hasher :: default ( ) ,
8280 }
8381}
8482
@@ -127,7 +125,7 @@ pub fn bytes(
127125pub fn bytes_with_hasher (
128126 read : & mut dyn std:: io:: Read ,
129127 num_bytes_from_start : u64 ,
130- mut hasher : Sha1 ,
128+ mut hasher : Hasher ,
131129 progress : & mut dyn crate :: progress:: Progress ,
132130 should_interrupt : & std:: sync:: atomic:: AtomicBool ,
133131) -> std:: io:: Result < gix_hash:: ObjectId > {
@@ -160,12 +158,12 @@ pub fn bytes_with_hasher(
160158
161159#[ cfg( any( feature = "rustsha1" , feature = "fast-sha1" ) ) ]
162160mod write {
163- use crate :: hash:: Sha1 ;
161+ use crate :: hash:: Hasher ;
164162
165163 /// A utility to automatically generate a hash while writing into an inner writer.
166164 pub struct Write < T > {
167165 /// The hash implementation.
168- pub hash : Sha1 ,
166+ pub hash : Hasher ,
169167 /// The inner writer.
170168 pub inner : T ,
171169 }
@@ -194,7 +192,7 @@ mod write {
194192 match object_hash {
195193 gix_hash:: Kind :: Sha1 => Write {
196194 inner,
197- hash : Sha1 :: default ( ) ,
195+ hash : Hasher :: default ( ) ,
198196 } ,
199197 }
200198 }
0 commit comments