summaryrefslogtreecommitdiffstats
path: root/src/db/model.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/model.rs')
-rw-r--r--src/db/model.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/db/model.rs b/src/db/model.rs
index 07065c5..e962d6f 100644
--- a/src/db/model.rs
+++ b/src/db/model.rs
@@ -58,11 +58,14 @@ impl Identity {
/// The hash that makes I3 a fact: two byte-identical inputs never produce
/// two candidates, and any change to what becomes a byte in the artifact
/// produces a new one.
+ ///
/// A digest of the canonical JSON of the identity tuple. This is the value
/// an approval must echo: two candidates share an `identity_hash` only if
- /// every pin, digest and version in them is identical.
- pub fn hash(&self) -> String {
- format!("sha256:{}", hash::hex(hash::canonical_json(self).as_bytes()))
+ /// every pin, digest and version in them is identical. A value that cannot
+ /// be serialized is an error rather than a digest — a shared fallback digest
+ /// would be the one way two identities could collide by accident.
+ pub fn hash(&self) -> crate::error::Result<String> {
+ Ok(format!("sha256:{}", hash::hex(hash::canonical_json(self)?.as_bytes())))
}
}