diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-05-09 13:05:38 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-05-09 13:05:38 -0400 |
commit | 753fc1661d9b5275ee7048353872f10bcd9c2953 (patch) | |
tree | 62dbbc1dc4b466765ffd4a0fc66fab4259b76d1f /src/libstore/content-address.cc | |
parent | d3c125e5a8ab8ffa1a1ed614b1e174f5670a881c (diff) |
Cleanups to content address types
Diffstat (limited to 'src/libstore/content-address.cc')
-rw-r--r-- | src/libstore/content-address.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index 167f7af6c..b62818e11 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -21,7 +21,8 @@ std::string makeFileIngestionPrefix(FileIngestionMethod m) } } -std::string ContentAddressMethod::renderPrefix() const { +std::string ContentAddressMethod::renderPrefix() const +{ return std::visit(overloaded { [](TextIngestionMethod) -> std::string { return "text:"; }, [](FileIngestionMethod m2) { @@ -113,7 +114,8 @@ static std::pair<ContentAddressMethod, HashType> parseContentAddressMethodPrefix throw UsageError("content address prefix '%s' is unrecognized. Recogonized prefixes are 'text' or 'fixed'", prefix); } -ContentAddress ContentAddress::parse(std::string_view rawCa) { +ContentAddress ContentAddress::parse(std::string_view rawCa) +{ auto rest = rawCa; auto [caMethod, hashType_] = parseContentAddressMethodPrefix(rest); @@ -155,7 +157,7 @@ std::string renderContentAddress(std::optional<ContentAddress> ca) } ContentAddress ContentAddress::fromParts( - ContentAddressMethod method, Hash hash) + ContentAddressMethod method, Hash hash) noexcept { return std::visit(overloaded { [&](TextIngestionMethod _) -> ContentAddress { @@ -196,7 +198,8 @@ const Hash & ContentAddress::getHash() const }, raw); } -std::string ContentAddress::printMethodAlgo() const { +std::string ContentAddress::printMethodAlgo() const +{ return getMethod().renderPrefix() + printHashType(getHash().type); } @@ -211,7 +214,8 @@ size_t StoreReferences::size() const return (self ? 1 : 0) + others.size(); } -ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const ContentAddress & ca) { +ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const ContentAddress & ca) noexcept +{ return std::visit(overloaded { [&](const TextHash & h) -> ContentAddressWithReferences { return TextInfo { |