Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
common-protocol.hh
Go to the documentation of this file.
1#pragma once
3
4#include "serialise.hh"
5
6namespace nix {
7
8struct StoreDirConfig;
9struct Source;
10
11// items being serialized
12class StorePath;
13struct ContentAddress;
14struct DrvOutput;
15struct Realisation;
16
17
26{
31 struct ReadConn {
32 Source & from;
33 };
34
39 struct WriteConn {
40 Sink & to;
41 };
42
43 template<typename T>
44 struct Serialise;
45
50 template<typename T>
51 static void write(const StoreDirConfig & store, WriteConn conn, const T & t)
52 {
54 }
55};
56
57#define DECLARE_COMMON_SERIALISER(T) \
58 struct CommonProto::Serialise< T > \
59 { \
60 static T read(const StoreDirConfig & store, CommonProto::ReadConn conn); \
61 static void write(const StoreDirConfig & store, CommonProto::WriteConn conn, const T & str); \
62 }
63
64template<>
65DECLARE_COMMON_SERIALISER(std::string);
66template<>
67DECLARE_COMMON_SERIALISER(StorePath);
68template<>
69DECLARE_COMMON_SERIALISER(ContentAddress);
70template<>
71DECLARE_COMMON_SERIALISER(DrvOutput);
72template<>
73DECLARE_COMMON_SERIALISER(Realisation);
74
75template<typename T>
76DECLARE_COMMON_SERIALISER(std::vector<T>);
77template<typename T>
78DECLARE_COMMON_SERIALISER(std::set<T>);
79template<typename... Ts>
80DECLARE_COMMON_SERIALISER(std::tuple<Ts...>);
81
82#define COMMA_ ,
83template<typename K, typename V>
84DECLARE_COMMON_SERIALISER(std::map<K COMMA_ V>);
85#undef COMMA_
86
101template<>
102DECLARE_COMMON_SERIALISER(std::optional<StorePath>);
103template<>
104DECLARE_COMMON_SERIALISER(std::optional<ContentAddress>);
105
106}
Definition path.hh:27
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 common-protocol.hh:26
static void write(const StoreDirConfig &store, WriteConn conn, const T &t)
Definition common-protocol.hh:51
Definition content-address.hh:153
Definition realisation.hh:24
Definition realisation.hh:49
Definition serialise.hh:20
Definition serialise.hh:68
Definition store-dir-config.hh:22