diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-05 20:37:48 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-05 20:37:48 +0000 |
commit | 6c66331d5c34d97092a9b5e2832fed73e0da3c87 (patch) | |
tree | def96b2ea891dfaceb7f297e2aedad519e88e1f8 /src/libstore/worker-protocol.hh | |
parent | ed96e603e116123c1e44f5108b67b472b2c96538 (diff) |
WIP: Put the worker protocol `read` and `write` in a namespace to disambig
Diffstat (limited to 'src/libstore/worker-protocol.hh')
-rw-r--r-- | src/libstore/worker-protocol.hh | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index 384b81f08..fdd700668 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -74,6 +74,10 @@ void writeStorePaths(const Store & store, Sink & out, const StorePathSet & paths template<typename T> struct Phantom {}; + +namespace worker_proto { +/* FIXME maybe move more stuff inside here */ + template<typename T> std::map<std::string, T> read(const Store & store, Source & from, Phantom<std::map<std::string, T>> _) { @@ -81,7 +85,7 @@ std::map<std::string, T> read(const Store & store, Source & from, Phantom<std::m auto size = (size_t)readInt(from); while (size--) { auto thisKey = readString(from); - resMap.insert_or_assign(std::move(thisKey), read(store, from, Phantom<T> {})); + resMap.insert_or_assign(std::move(thisKey), nix::worker_proto::read(store, from, Phantom<T> {})); } return resMap; } @@ -92,7 +96,7 @@ void write(const Store & store, Sink & out, const std::map<string, T> & resMap) out << resMap.size(); for (auto & i : resMap) { out << i.first; - write(store, out, i.second); + nix::worker_proto::write(store, out, i.second); } } @@ -104,7 +108,7 @@ std::optional<T> read(const Store & store, Source & from, Phantom<std::optional< case 0: return std::nullopt; case 1: - return read(store, from, Phantom<T> {}); + return nix::worker_proto::read(store, from, Phantom<T> {}); default: throw Error("got an invalid tag bit for std::optional: %#04x", tag); } @@ -115,13 +119,16 @@ void write(const Store & store, Sink & out, const std::optional<T> & optVal) { out << (optVal ? 1 : 0); if (optVal) - write(store, out, *optVal); + nix::worker_proto::write(store, out, *optVal); } StorePath read(const Store & store, Source & from, Phantom<StorePath> _); void write(const Store & store, Sink & out, const StorePath & storePath); +} + + StorePathCAMap readStorePathCAMap(const Store & store, Source & from); void writeStorePathCAMap(const Store & store, Sink & out, const StorePathCAMap & paths); |