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) {
case FileIngestionMethod::Flat:

View file

@ -11,17 +11,16 @@ namespace nix {
* 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 {
Flat = false,
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;
@ -29,9 +28,13 @@ struct FixedOutputHashMethod {
/* Compute the prefix to the hash algorithm which indicates how the files were
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<
TextHashMethod,
FixedOutputHashMethod
@ -86,6 +89,7 @@ std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt);
Hash getContentAddressHash(const ContentAddress & ca);
/*
* References set
*/