Slight cleanups

This commit is contained in:
John Ericson 2022-04-19 22:25:21 +00:00
parent 2c21cb6720
commit 13c669105c
2 changed files with 12 additions and 8 deletions

View file

@ -10,7 +10,7 @@ std::string FixedOutputHash::printMethodAlgo() const
} }
std::string makeFileIngestionPrefix(const FileIngestionMethod m) std::string makeFileIngestionPrefix(FileIngestionMethod m)
{ {
switch (m) { switch (m) {
case FileIngestionMethod::Flat: case FileIngestionMethod::Flat:

View file

@ -11,17 +11,16 @@ namespace nix {
* Content addressing method * Content addressing method
*/ */
/* We only have one way to hash text with references, so this is a single-value
type, mainly useful with std::variant.
*/
struct TextHashMethod : std::monostate { };
enum struct FileIngestionMethod : uint8_t { enum struct FileIngestionMethod : uint8_t {
Flat = false, Flat = false,
Recursive = true 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 { struct FixedOutputHashMethod {
FileIngestionMethod fileIngestionMethod; FileIngestionMethod fileIngestionMethod;
HashType hashType; HashType hashType;
@ -29,9 +28,13 @@ struct FixedOutputHashMethod {
/* Compute the prefix to the hash algorithm which indicates how the files were /* Compute the prefix to the hash algorithm which indicates how the files were
ingested. */ ingested. */
std::string makeFileIngestionPrefix(const FileIngestionMethod m); std::string makeFileIngestionPrefix(FileIngestionMethod m);
/* Just the type of a content address. Combine with the hash itself, and we
have a `ContentAddress` as defined below. Combine that, in turn, with info
on references, and we have `ContentAddressWithReferences`, as defined
further below. */
typedef std::variant< typedef std::variant<
TextHashMethod, TextHashMethod,
FixedOutputHashMethod FixedOutputHashMethod
@ -86,6 +89,7 @@ std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt);
Hash getContentAddressHash(const ContentAddress & ca); Hash getContentAddressHash(const ContentAddress & ca);
/* /*
* References set * References set
*/ */