Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
serve-protocol-impl.hh
Go to the documentation of this file.
1#pragma once
10
11#include "serve-protocol.hh"
13
14namespace nix {
15
16/* protocol-agnostic templates */
17
18#define SERVE_USE_LENGTH_PREFIX_SERIALISER(TEMPLATE, T) \
19 TEMPLATE T ServeProto::Serialise< T >::read(const StoreDirConfig & store, ServeProto::ReadConn conn) \
20 { \
21 return LengthPrefixedProtoHelper<ServeProto, T >::read(store, conn); \
22 } \
23 TEMPLATE void ServeProto::Serialise< T >::write(const StoreDirConfig & store, ServeProto::WriteConn conn, const T & t) \
24 { \
25 LengthPrefixedProtoHelper<ServeProto, T >::write(store, conn, t); \
26 }
27
28SERVE_USE_LENGTH_PREFIX_SERIALISER(template<typename T>, std::vector<T>)
29SERVE_USE_LENGTH_PREFIX_SERIALISER(template<typename T>, std::set<T>)
30SERVE_USE_LENGTH_PREFIX_SERIALISER(template<typename... Ts>, std::tuple<Ts...>)
31
32#define SERVE_USE_LENGTH_PREFIX_SERIALISER_COMMA ,
33SERVE_USE_LENGTH_PREFIX_SERIALISER(
34 template<typename K SERVE_USE_LENGTH_PREFIX_SERIALISER_COMMA typename V>,
35 std::map<K SERVE_USE_LENGTH_PREFIX_SERIALISER_COMMA V>)
36
37
40template<typename T>
42{
43 static T read(const StoreDirConfig & store, ServeProto::ReadConn conn)
44 {
46 CommonProto::ReadConn { .from = conn.from });
47 }
48 static void write(const StoreDirConfig & store, ServeProto::WriteConn conn, const T & t)
49 {
51 CommonProto::WriteConn { .to = conn.to },
52 t);
53 }
54};
55
56/* protocol-specific templates */
57
58}
ChunkedVector< std::string, 8192 > store
Definition lexer.l:1011
T t
Definition lexer.l:154
Definition common-protocol.hh:31
Definition common-protocol.hh:44
Definition common-protocol.hh:39
Definition serve-protocol.hh:48
Definition serve-protocol-impl.hh:42
Definition serve-protocol.hh:57
Definition store-dir-config.hh:22