Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
worker-protocol-impl.hh
Go to the documentation of this file.
1#pragma once
10
12#include "lix/libstore/length-prefixed-protocol-helper.hh"
13
14namespace nix {
15
16/* protocol-agnostic templates */
17
18#define WORKER_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
19 TEMPLATE T WorkerProto::Serialise< T >::read(const Store & store, WorkerProto::ReadConn conn) \
20 { \
21 return LengthPrefixedProtoHelper<WorkerProto, T >::read(store, conn); \
22 } \
23 /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
24 TEMPLATE [[nodiscard]] WireFormatGenerator WorkerProto::Serialise< T >::write(const Store & store, WorkerProto::WriteConn conn, const T & t) \
25 { \
26 return LengthPrefixedProtoHelper<WorkerProto, T >::write(store, conn, t); \
27 }
28
29WORKER_USE_LENGTH_PREFIX_SERIALISER(template<typename T>, std::vector<T>)
30WORKER_USE_LENGTH_PREFIX_SERIALISER(template<typename T>, std::set<T>)
31WORKER_USE_LENGTH_PREFIX_SERIALISER(template<typename... Ts>, std::tuple<Ts...>)
32
33#define COMMA_ ,
34WORKER_USE_LENGTH_PREFIX_SERIALISER(
35 template<typename K COMMA_ typename V>,
36 std::map<K COMMA_ V>)
37#undef COMMA_
38
42template<typename T>
44{
45 static T read(const Store & store, WorkerProto::ReadConn conn)
46 {
47 return CommonProto::Serialise<T>::read(store,
48 CommonProto::ReadConn { .from = conn.from });
49 }
50 [[nodiscard]]
51 static WireFormatGenerator write(const Store & store, WorkerProto::WriteConn conn, const T & t)
52 {
53 return CommonProto::Serialise<T>::write(store,
54 CommonProto::WriteConn {},
55 t);
56 }
57};
58
59/* protocol-specific templates */
60
61}
Definition worker-protocol.hh:104
static WireFormatGenerator write(const Store &store, WriteConn conn, const T &t)
Definition worker-protocol.hh:134