1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-20 17:29:36 +01:00

WIP more progress

This commit is contained in:
John Ericson 2020-06-01 19:26:40 -04:00
parent da39092a39
commit 754c910953
6 changed files with 28 additions and 25 deletions

View file

@ -24,4 +24,22 @@ std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash)
+ hash.to_string();
}
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
std::string renderContentAddress(ContentAddress ca) {
return std::visit(overloaded {
[](TextHash th) {
return "text:" + th.hash.to_string();
},
[](FileSystemHash fsh) {
return makeFixedOutputCA(fsh.method, fsh.hash);
}
}, ca);
}
std::string renderContentAddress(std::optionalContent<Address> ca) {
return ca ? renderContentAddress(*ca) else "";
}
}