Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
content-address.hh
Go to the documentation of this file.
1#pragma once
3
4#include <variant>
5#include "hash.hh"
6#include "path.hh"
8#include "variant-wrapper.hh"
9
10namespace nix {
11
12/*
13 * Content addressing method
14 */
15
20std::string_view makeFileIngestionPrefix(FileIngestionMethod m);
21
31{
32 enum struct Raw {
41
51
62
72 };
73
74 Raw raw;
75
76 bool operator ==(const ContentAddressMethod &) const = default;
77 auto operator <=>(const ContentAddressMethod &) const = default;
78
79 MAKE_WRAPPER_CONSTRUCTOR(ContentAddressMethod);
80
86 static ContentAddressMethod parse(std::string_view rawCaMethod);
87
93 std::string_view render() const;
94
104 static ContentAddressMethod parsePrefix(std::string_view & m);
105
111 std::string_view renderPrefix() const;
112
116 static std::pair<ContentAddressMethod, HashAlgorithm> parseWithAlgo(std::string_view rawCaMethod);
117
124 std::string renderWithAlgo(HashAlgorithm ha) const;
125
133};
134
135
136/*
137 * Mini content address
138 */
139
153{
158
163
164 bool operator ==(const ContentAddress &) const = default;
165 auto operator <=>(const ContentAddress &) const = default;
166
172 std::string render() const;
173
174 static ContentAddress parse(std::string_view rawCa);
175
176 static std::optional<ContentAddress> parseOpt(std::string_view rawCaOpt);
177
178 std::string printMethodAlgo() const;
179};
180
185std::string renderContentAddress(std::optional<ContentAddress> ca);
186
187
188/*
189 * Full content address
190 *
191 * See the schema for store paths in store-api.cc
192 */
193
201{
205 StorePathSet others;
206
210 bool self = false;
211
216 bool empty() const;
217
222 size_t size() const;
223
224 bool operator ==(const StoreReferences &) const = default;
225 // TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
226 //auto operator <=>(const StoreReferences &) const = default;
227};
228
229// This matches the additional info that we need for makeTextPath
231{
236
241 StorePathSet references;
242
243 bool operator ==(const TextInfo &) const = default;
244 // TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
245 //auto operator <=>(const TextInfo &) const = default;
246};
247
249{
254
259
264
265 bool operator ==(const FixedOutputInfo &) const = default;
266 // TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
267 //auto operator <=>(const FixedOutputInfo &) const = default;
268};
269
276{
277 typedef std::variant<
278 TextInfo,
280 > Raw;
281
282 Raw raw;
283
284 bool operator ==(const ContentAddressWithReferences &) const = default;
285 // TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
286 //auto operator <=>(const ContentAddressWithReferences &) const = default;
287
288 MAKE_WRAPPER_CONSTRUCTOR(ContentAddressWithReferences);
289
295
310 ContentAddressMethod method, Hash hash, StoreReferences refs);
311
312 ContentAddressMethod getMethod() const;
313
314 Hash getHash() const;
315};
316
317}
FileIngestionMethod
Definition file-content-address.hh:99
std::variant< T, Suggestions > Raw
Definition lexer.l:314
Definition content-address.hh:31
Raw
Definition content-address.hh:32
@ Git
Definition content-address.hh:61
@ Flat
Definition content-address.hh:40
@ Text
Definition content-address.hh:71
@ NixArchive
Definition content-address.hh:50
static std::pair< ContentAddressMethod, HashAlgorithm > parseWithAlgo(std::string_view rawCaMethod)
Definition content-address.cc:204
static ContentAddressMethod parsePrefix(std::string_view &m)
Definition content-address.cc:83
static ContentAddressMethod parse(std::string_view rawCaMethod)
Definition content-address.cc:60
std::string renderWithAlgo(HashAlgorithm ha) const
Definition content-address.cc:117
std::string_view render() const
Definition content-address.cc:23
FileIngestionMethod getFileIngestionMethod() const
Definition content-address.cc:122
std::string_view renderPrefix() const
Definition content-address.cc:69
Definition content-address.hh:276
static ContentAddressWithReferences fromParts(ContentAddressMethod method, Hash hash, StoreReferences refs)
Definition content-address.cc:261
static ContentAddressWithReferences withoutRefs(const ContentAddress &) noexcept
Definition content-address.cc:240
Definition content-address.hh:153
Hash hash
Definition content-address.hh:162
ContentAddressMethod method
Definition content-address.hh:157
std::string render() const
Definition content-address.cc:138
Definition content-address.hh:249
FileIngestionMethod method
Definition content-address.hh:253
StoreReferences references
Definition content-address.hh:263
Hash hash
Definition content-address.hh:258
Definition hash.hh:45
Definition content-address.hh:201
bool empty() const
Definition content-address.cc:230
StorePathSet others
Definition content-address.hh:205
bool self
Definition content-address.hh:210
size_t size() const
Definition content-address.cc:235
Definition content-address.hh:231
Hash hash
Definition content-address.hh:235
StorePathSet references
Definition content-address.hh:241