Skip to content

Commit feccdf8

Browse files
authored
Merge pull request #2218 from GitoxideLabs/hash
hash: Future Proofing - rewritten commits of #2213
2 parents f38e1c9 + 4a0b84a commit feccdf8

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

gix-hash/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ doctest = false
1616
test = false
1717

1818
[features]
19+
default = ["sha1"]
20+
## Support for SHA-1 digests.
21+
sha1 = []
1922
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
2023
serde = ["dep:serde", "faster-hex/serde"]
2124

gix-hash/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
1010
#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
1111

12+
// Remove this once other hashes (e.g., SHA-256, and potentially others)
13+
// are supported, and this crate can build without [`ObjectId::Sha1`].
14+
#[cfg(not(feature = "sha1"))]
15+
compile_error!("Please set the `sha1` feature flag");
16+
1217
#[path = "oid.rs"]
1318
mod borrowed;
1419
pub use borrowed::{oid, Error};

gix-hash/src/object_id.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{borrowed::oid, Kind, SIZE_OF_SHA1_DIGEST};
99
/// An owned hash identifying objects, most commonly `Sha1`
1010
#[derive(PartialEq, Eq, Ord, PartialOrd, Clone, Copy)]
1111
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12+
#[non_exhaustive]
1213
pub enum ObjectId {
1314
/// A SHA 1 hash digest
1415
Sha1([u8; SIZE_OF_SHA1_DIGEST]),

0 commit comments

Comments
 (0)