Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
common-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 COMMON_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
19 TEMPLATE T CommonProto::Serialise< T >::read(const Store & store, CommonProto::ReadConn conn) \
20 { \
21 return LengthPrefixedProtoHelper<CommonProto, T >::read(store, conn); \
22 } \
23 /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
24 TEMPLATE [[nodiscard]] WireFormatGenerator CommonProto::Serialise< T >::write(const Store & store, CommonProto::WriteConn conn, const T & t) \
25 { \
26 return LengthPrefixedProtoHelper<CommonProto, T >::write(store, conn, t); \
27 }
28
29COMMON_USE_LENGTH_PREFIX_SERIALISER(template<typename T>, std::vector<T>)
30COMMON_USE_LENGTH_PREFIX_SERIALISER(template<typename T>, std::set<T>)
31COMMON_USE_LENGTH_PREFIX_SERIALISER(template<typename... Ts>, std::tuple<Ts...>)
32
33#define COMMA_ ,
34COMMON_USE_LENGTH_PREFIX_SERIALISER(
35 template<typename K COMMA_ typename V>,
36 std::map<K COMMA_ V>)
37#undef COMMA_
38
39
40/* protocol-specific templates */
41
42}