diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-07 18:51:01 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-07 18:51:01 +0000 |
commit | 8f92bb5ad9856daaa8488a5dad206b980a2aacb5 (patch) | |
tree | 6a3470a7ac7bb85580116dc3dad50d597c95a5f9 /src/libstore/worker-protocol.hh | |
parent | 46f9dd56da7d2af82148c47e40108f3c11ffe4d7 (diff) | |
parent | f7ba16f9cbc27b141f1797a7c4f1fd3243f31683 (diff) |
Merge branch 'drv-outputs-map-allow-missing' of github.com:obsidiansystems/nix into templated-daemon-protocol
Diffstat (limited to 'src/libstore/worker-protocol.hh')
-rw-r--r-- | src/libstore/worker-protocol.hh | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index 1e8fd027c..f3039dc98 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -72,23 +72,16 @@ struct WorkerProto { static void write(const Store & store, Sink & out, const T & t); }; -template<> -struct WorkerProto<std::string> { - static std::string read(const Store & store, Source & from); - static void write(const Store & store, Sink & out, const std::string & t); -}; - -template<> -struct WorkerProto<StorePath> { - static StorePath read(const Store & store, Source & from); - static void write(const Store & store, Sink & out, const StorePath & t); -}; +#define MAKE_WORKER_PROTO(T) \ + template<> \ + struct WorkerProto< T > { \ + static T read(const Store & store, Source & from); \ + static void write(const Store & store, Sink & out, const T & t); \ + } -template<> -struct WorkerProto<ContentAddress> { - static ContentAddress read(const Store & store, Source & from); - static void write(const Store & store, Sink & out, const ContentAddress & t); -}; +MAKE_WORKER_PROTO(std::string); +MAKE_WORKER_PROTO(StorePath); +MAKE_WORKER_PROTO(ContentAddress); template<typename T> struct WorkerProto<std::set<T>> { @@ -164,4 +157,13 @@ struct WorkerProto<std::optional<T>> { }; +/* Specialization which uses and empty string for the empty case, taking + advantage of the fact these types always serialize to non-empty strings. + This is done primarily for backwards compatability, so that T <= + std::optional<T>, where <= is the compatability partial order, T is one of + the types below. + */ +MAKE_WORKER_PROTO(std::optional<StorePath>); +MAKE_WORKER_PROTO(std::optional<ContentAddress>); + } |