diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-04 03:46:48 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-04 04:36:14 +0100 |
commit | f17e7b185597715049fa7a12e6a0512ef66801b6 (patch) | |
tree | c7a59f65cbfd674ae93ba0a350fdeb9aec145bee /src/libstore | |
parent | 79dd9efe384cd70e04fe3fd3ee03c0b8d5ee8182 (diff) |
Merge pull request #8923 from obsidiansystems/test-proto
Unit test some worker protocol serializers
(cherry picked from commit c6faef61a6f31c71146aee5d88168e861df9a22a)
Change-Id: I99e36f5f17eb7642211a4e42a16b143424f164b4
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/worker-protocol-impl.hh | 16 | ||||
-rw-r--r-- | src/libstore/worker-protocol.hh | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/libstore/worker-protocol-impl.hh b/src/libstore/worker-protocol-impl.hh index d3d2792ff..4f797f95a 100644 --- a/src/libstore/worker-protocol-impl.hh +++ b/src/libstore/worker-protocol-impl.hh @@ -75,4 +75,20 @@ void WorkerProto::Serialise<std::map<K, V>>::write(const Store & store, WorkerPr } } +template<typename... Ts> +std::tuple<Ts...> WorkerProto::Serialise<std::tuple<Ts...>>::read(const Store & store, WorkerProto::ReadConn conn) +{ + return std::tuple<Ts...> { + WorkerProto::Serialise<Ts>::read(store, conn)..., + }; +} + +template<typename... Ts> +void WorkerProto::Serialise<std::tuple<Ts...>>::write(const Store & store, WorkerProto::WriteConn conn, const std::tuple<Ts...> & res) +{ + std::apply([&]<typename... Us>(const Us &... args) { + (WorkerProto::Serialise<Us>::write(store, conn, args), ...); + }, res); +} + } diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index ff762c924..70a5bddb9 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -28,6 +28,8 @@ class Store; struct Source; // items being serialised +class StorePath; +struct ContentAddress; struct DerivedPath; struct DrvOutput; struct Realisation; @@ -220,6 +222,8 @@ template<typename T> MAKE_WORKER_PROTO(std::vector<T>); template<typename T> MAKE_WORKER_PROTO(std::set<T>); +template<typename... Ts> +MAKE_WORKER_PROTO(std::tuple<Ts...>); template<typename K, typename V> #define X_ std::map<K, V> |