History

change!: SIZE_OF_SHA1_DIGEST is now private (#279)

Replace it with your own constant derived from `git_hash::Kind::Sha1.len_in_bytes()` or even better, make this value configurable once it's clear how differently sized hashes are used within gits files.

Sebastian Thiel committed 4 years ago

Commit b596fa01 parent 265b8ec1 file · +2 −8Browse files

Unified · Split

git-hash/src/lib.rs+2−8
@@ -49,19 +49,13 @@ pub mod decode { · 48 unmodified lines
49 type Err = Error;49 type Err = Error;
50 50
51 fn from_str(s: &str) -> Result<Self, Self::Err> {51 fn from_str(s: &str) -> Result<Self, Self::Err> {
52 use hex::FromHex;52 Self::from_hex(s.as_bytes())
53 match s.len() {
54 40 => Ok(ObjectId::Sha1(
55 <[u8; 20]>::from_hex(s).expect("our length check is correct thus we can decode hex"),
56 )),
57 len => Err(Error::InvalidHexEncodingLength(len)),
58 }
59 }53 }
60 }54 }
61}55}
62 56
63/// The size of a SHA1 hash digest in bytes57/// The size of a SHA1 hash digest in bytes
64pub const SIZE_OF_SHA1_DIGEST: usize = 20;58const SIZE_OF_SHA1_DIGEST: usize = 20;
65 59
66/// Denotes the kind of function to produce a `Id`60/// Denotes the kind of function to produce a `Id`
67#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]61#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]