diff options
Diffstat (limited to 'src/libstore/content-address.hh')
-rw-r--r-- | src/libstore/content-address.hh | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh index 2f98950fb..962b63e83 100644 --- a/src/libstore/content-address.hh +++ b/src/libstore/content-address.hh @@ -46,13 +46,6 @@ enum struct FileIngestionMethod : uint8_t { */ std::string makeFileIngestionPrefix(FileIngestionMethod m); -struct FixedOutputHashMethod { - FileIngestionMethod fileIngestionMethod; - HashType hashType; - - GENERATE_CMP(FixedOutputHashMethod, me->fileIngestionMethod, me->hashType); -}; - /** * An enumeration of all the ways we can serialize file system objects. * @@ -65,7 +58,7 @@ struct ContentAddressMethod { typedef std::variant< TextHashMethod, - FixedOutputHashMethod + FileIngestionMethod > Raw; Raw raw; @@ -77,9 +70,23 @@ struct ContentAddressMethod : raw(std::forward<decltype(arg)>(arg)...) { } - static ContentAddressMethod parse(std::string_view rawCaMethod); - std::string render() const; + /** + * Parse and pretty print the algorithm which indicates how the files + * were ingested, with the the fixed output case not prefixed for back + * compat. + */ + static ContentAddressMethod parsePrefix(std::string_view & m); + + std::string renderPrefix() const; + + /** + * Parse and pretty print a content addressing method and hash type in a + * nicer way, prefixing both cases. + */ + static std::pair<ContentAddressMethod, HashType> parse(std::string_view rawCaMethod); + + std::string render(HashType ht) const; }; @@ -248,6 +255,26 @@ struct ContentAddressWithReferences * assuming no references in all cases. */ static ContentAddressWithReferences withoutRefs(const ContentAddress &); + + /** + * Create a ContentAddressWithReferences from 3 parts: + * + * @param method Way ingesting the file system data. + * + * @param hash Hash of ingested file system data. + * + * @param refs References to other store objects or oneself. + * + * Do note that not all combinations are supported. + */ + static ContentAddressWithReferences fromParts( + ContentAddressMethod method, Hash hash, StoreReferences refs); + + ContentAddressMethod getMethod() const; + + Hash getHash() const; + + std::string printMethodAlgo() const; }; } |