mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 14:32:42 +01:00
Make DerivedPathWithHints a newtype
This allows us to namespace its constructors under it.
This commit is contained in:
parent
9b805d36ac
commit
179582872d
8 changed files with 44 additions and 31 deletions
|
|
@ -11,7 +11,7 @@ nlohmann::json DerivedPath::Opaque::toJSON(ref<Store> store) const {
|
|||
return res;
|
||||
}
|
||||
|
||||
nlohmann::json DerivedPathWithHintsBuilt::toJSON(ref<Store> store) const {
|
||||
nlohmann::json DerivedPathWithHints::Built::toJSON(ref<Store> store) const {
|
||||
nlohmann::json res;
|
||||
res["drvPath"] = store->printStorePath(drvPath);
|
||||
for (const auto& [output, path] : outputs) {
|
||||
|
|
@ -25,7 +25,7 @@ nlohmann::json derivedPathsWithHintsToJSON(const DerivedPathsWithHints & buildab
|
|||
for (const DerivedPathWithHints & buildable : buildables) {
|
||||
std::visit([&res, store](const auto & buildable) {
|
||||
res.push_back(buildable.toJSON(store));
|
||||
}, buildable);
|
||||
}, buildable.raw());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,11 +56,24 @@ struct DerivedPathWithHintsBuilt {
|
|||
static DerivedPathWithHintsBuilt parse(const Store & store, std::string_view);
|
||||
};
|
||||
|
||||
using DerivedPathWithHints = std::variant<
|
||||
using _DerivedPathWithHintsRaw = std::variant<
|
||||
DerivedPath::Opaque,
|
||||
DerivedPathWithHintsBuilt
|
||||
>;
|
||||
|
||||
struct DerivedPathWithHints : _DerivedPathWithHintsRaw {
|
||||
using Raw = _DerivedPathWithHintsRaw;
|
||||
using Raw::Raw;
|
||||
|
||||
using Opaque = DerivedPathOpaque;
|
||||
using Built = DerivedPathWithHintsBuilt;
|
||||
|
||||
inline const Raw & raw() const {
|
||||
return static_cast<const Raw &>(*this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef std::vector<DerivedPathWithHints> DerivedPathsWithHints;
|
||||
|
||||
nlohmann::json derivedPathsWithHintsToJSON(const DerivedPathsWithHints & buildables, ref<Store> store);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue