aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/content-address.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-09 13:05:38 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-09 13:05:38 -0400
commit753fc1661d9b5275ee7048353872f10bcd9c2953 (patch)
tree62dbbc1dc4b466765ffd4a0fc66fab4259b76d1f /src/libstore/content-address.hh
parentd3c125e5a8ab8ffa1a1ed614b1e174f5670a881c (diff)
Cleanups to content address types
Diffstat (limited to 'src/libstore/content-address.hh')
-rw-r--r--src/libstore/content-address.hh23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh
index 4183ac1e7..03a2e2a23 100644
--- a/src/libstore/content-address.hh
+++ b/src/libstore/content-address.hh
@@ -81,17 +81,30 @@ struct ContentAddressMethod
* Parse the prefix tag which indicates how the files
* were ingested, with the fixed output case not prefixed for back
* compat.
+ *
+ * @param [in] m A string that should begin with the prefix.
+ * @param [out] m The remainder of the string after the prefix.
*/
static ContentAddressMethod parsePrefix(std::string_view & m);
+ /**
+ * Render the prefix tag which indicates how the files wre ingested.
+ *
+ * The rough inverse of `parsePrefix()`.
+ */
std::string renderPrefix() const;
/**
- * Parse and pretty print a content addressing method and hash type in a
- * nicer way, prefixing both cases.
+ * Parse a content addressing method and hash type.
*/
static std::pair<ContentAddressMethod, HashType> parse(std::string_view rawCaMethod);
+ /**
+ * Render a content addressing method and hash type in a
+ * nicer way, prefixing both cases.
+ *
+ * The rough inverse of `parse()`.
+ */
std::string render(HashType ht) const;
};
@@ -178,7 +191,7 @@ struct ContentAddress
* @param hash Hash of ingested file system data.
*/
static ContentAddress fromParts(
- ContentAddressMethod method, Hash hash);
+ ContentAddressMethod method, Hash hash) noexcept;
ContentAddressMethod getMethod() const;
@@ -187,6 +200,10 @@ struct ContentAddress
std::string printMethodAlgo() const;
};
+/**
+ * Render the `ContentAddress` if it exists to a string, return empty
+ * string otherwise.
+ */
std::string renderContentAddress(std::optional<ContentAddress> ca);