summaryrefslogtreecommitdiff
path: root/src/buildtool/crypto/hash_function.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-09-23 12:09:44 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-10-25 13:00:43 +0200
commit7571f74dbc53e9b4fe3b9000662ca686960db78e (patch)
treeba1adfd9bd5a2024de2c0ddb0e8c9e76e947bdc2 /src/buildtool/crypto/hash_function.hpp
parentbfefe45f8731e10a92f739d630a3c027fc72bc5b (diff)
downloadjustbuild-7571f74dbc53e9b4fe3b9000662ca686960db78e.tar.gz
StorageUtils: Add generation-aware rehashing ID file map
Such a file could be used to store mappings of digests from CAS or Git cache to digests of different hash type that represent same content.
Diffstat (limited to 'src/buildtool/crypto/hash_function.hpp')
-rw-r--r--src/buildtool/crypto/hash_function.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/buildtool/crypto/hash_function.hpp b/src/buildtool/crypto/hash_function.hpp
index 9e5a9c0b..530e0b2b 100644
--- a/src/buildtool/crypto/hash_function.hpp
+++ b/src/buildtool/crypto/hash_function.hpp
@@ -95,4 +95,15 @@ class HashFunction {
-> std::optional<std::pair<Hasher::HashDigest, std::uintmax_t>>;
};
+[[nodiscard]] constexpr auto ToString(HashFunction::Type type) noexcept -> const
+ char* {
+ switch (type) {
+ case HashFunction::Type::GitSHA1:
+ return "git-SHA1";
+ case HashFunction::Type::PlainSHA256:
+ return "plain-SHA256";
+ }
+ Ensures(false); // unreachable
+}
+
#endif // INCLUDED_SRC_BUILDTOOL_CRYPTO_HASH_FUNCTION_HPP