mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-11 08:46:16 +02:00
Organize content-address.hh a bit better
This commit is contained in:
parent
a0f369aa3f
commit
39c11c5c01
1 changed files with 29 additions and 24 deletions
|
@ -7,7 +7,7 @@
|
|||
namespace nix {
|
||||
|
||||
/*
|
||||
* Mini content address
|
||||
* Content addressing method
|
||||
*/
|
||||
|
||||
enum struct FileIngestionMethod : uint8_t {
|
||||
|
@ -15,6 +15,34 @@ enum struct FileIngestionMethod : uint8_t {
|
|||
Recursive = true
|
||||
};
|
||||
|
||||
/*
|
||||
We only have one way to hash text with references, so this is single-value
|
||||
type is only useful in std::variant.
|
||||
*/
|
||||
struct TextHashMethod { };
|
||||
|
||||
struct FixedOutputHashMethod {
|
||||
FileIngestionMethod fileIngestionMethod;
|
||||
HashType hashType;
|
||||
};
|
||||
|
||||
/* Compute the prefix to the hash algorithm which indicates how the files were
|
||||
ingested. */
|
||||
std::string makeFileIngestionPrefix(const FileIngestionMethod m);
|
||||
|
||||
|
||||
typedef std::variant<
|
||||
TextHashMethod,
|
||||
FixedOutputHashMethod
|
||||
> ContentAddressMethod;
|
||||
|
||||
ContentAddressMethod parseContentAddressMethod(std::string_view rawCaMethod);
|
||||
|
||||
std::string renderContentAddressMethod(ContentAddressMethod caMethod);
|
||||
|
||||
/*
|
||||
* Mini content address
|
||||
*/
|
||||
|
||||
struct TextHash {
|
||||
Hash hash;
|
||||
|
@ -43,10 +71,6 @@ typedef std::variant<
|
|||
FixedOutputHash // for path computed by makeFixedOutputPath
|
||||
> ContentAddress;
|
||||
|
||||
/* Compute the prefix to the hash algorithm which indicates how the files were
|
||||
ingested. */
|
||||
std::string makeFileIngestionPrefix(const FileIngestionMethod m);
|
||||
|
||||
std::string renderContentAddress(ContentAddress ca);
|
||||
|
||||
std::string renderContentAddress(std::optional<ContentAddress> ca);
|
||||
|
@ -57,25 +81,6 @@ std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt);
|
|||
|
||||
Hash getContentAddressHash(const ContentAddress & ca);
|
||||
|
||||
/*
|
||||
We only have one way to hash text with references, so this is single-value
|
||||
type is only useful in std::variant.
|
||||
*/
|
||||
struct TextHashMethod { };
|
||||
struct FixedOutputHashMethod {
|
||||
FileIngestionMethod fileIngestionMethod;
|
||||
HashType hashType;
|
||||
};
|
||||
|
||||
typedef std::variant<
|
||||
TextHashMethod,
|
||||
FixedOutputHashMethod
|
||||
> ContentAddressMethod;
|
||||
|
||||
ContentAddressMethod parseContentAddressMethod(std::string_view rawCaMethod);
|
||||
|
||||
std::string renderContentAddressMethod(ContentAddressMethod caMethod);
|
||||
|
||||
/*
|
||||
* References set
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue