Proxy -> Phantom to match Rust
Sorry, Haskell.
This commit is contained in:
parent
cf939055c8
commit
ed96e603e1
|
@ -58,7 +58,7 @@ void writeStorePathCAMap(const Store & store, Sink & out, const StorePathCAMap &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath read(const Store & store, Source & from, Proxy<StorePath> _)
|
StorePath read(const Store & store, Source & from, Phantom<StorePath> _)
|
||||||
{
|
{
|
||||||
return store.parseStorePath(readString(from));
|
return store.parseStorePath(readString(from));
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ std::map<std::string, std::optional<StorePath>> RemoteStore::queryDerivationOutp
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopQueryDerivationOutputMap << printStorePath(path);
|
conn->to << wopQueryDerivationOutputMap << printStorePath(path);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return read(*this, conn->from, Proxy<std::map<std::string, std::optional<StorePath>>> {});
|
return read(*this, conn->from, Phantom<std::map<std::string, std::optional<StorePath>>> {});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,16 +72,16 @@ void writeStorePaths(const Store & store, Sink & out, const StorePathSet & paths
|
||||||
|
|
||||||
/* To guide overloading */
|
/* To guide overloading */
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Proxy {};
|
struct Phantom {};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::map<std::string, T> read(const Store & store, Source & from, Proxy<std::map<std::string, T>> _)
|
std::map<std::string, T> read(const Store & store, Source & from, Phantom<std::map<std::string, T>> _)
|
||||||
{
|
{
|
||||||
std::map<string, T> resMap;
|
std::map<string, T> resMap;
|
||||||
auto size = (size_t)readInt(from);
|
auto size = (size_t)readInt(from);
|
||||||
while (size--) {
|
while (size--) {
|
||||||
auto thisKey = readString(from);
|
auto thisKey = readString(from);
|
||||||
resMap.insert_or_assign(std::move(thisKey), read(store, from, Proxy<T> {}));
|
resMap.insert_or_assign(std::move(thisKey), read(store, from, Phantom<T> {}));
|
||||||
}
|
}
|
||||||
return resMap;
|
return resMap;
|
||||||
}
|
}
|
||||||
|
@ -97,14 +97,14 @@ void write(const Store & store, Sink & out, const std::map<string, T> & resMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::optional<T> read(const Store & store, Source & from, Proxy<std::optional<T>> _)
|
std::optional<T> read(const Store & store, Source & from, Phantom<std::optional<T>> _)
|
||||||
{
|
{
|
||||||
auto tag = readNum<uint8_t>(from);
|
auto tag = readNum<uint8_t>(from);
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case 0:
|
case 0:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
case 1:
|
case 1:
|
||||||
return read(store, from, Proxy<T> {});
|
return read(store, from, Phantom<T> {});
|
||||||
default:
|
default:
|
||||||
throw Error("got an invalid tag bit for std::optional: %#04x", tag);
|
throw Error("got an invalid tag bit for std::optional: %#04x", tag);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ void write(const Store & store, Sink & out, const std::optional<T> & optVal)
|
||||||
write(store, out, *optVal);
|
write(store, out, *optVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePath read(const Store & store, Source & from, Proxy<StorePath> _);
|
StorePath read(const Store & store, Source & from, Phantom<StorePath> _);
|
||||||
|
|
||||||
void write(const Store & store, Sink & out, const StorePath & storePath);
|
void write(const Store & store, Sink & out, const StorePath & storePath);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue