diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-09-05 14:23:47 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-09-05 16:15:40 +0200 |
commit | 55846168dce4a296d87ef8fa582e6e72e304717e (patch) | |
tree | 9ad031aa60522290872080472fb22b5ac740d545 /libimagref | |
parent | 5399b8ca7bf6f478c56c815b23b2be9833a73505 (diff) |
Add variant of Ref::get_stored_hash() to get stored hash with custom hasher
Diffstat (limited to 'libimagref')
-rw-r--r-- | libimagref/src/reference.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index e1d0f02a..8df36f93 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -239,8 +239,13 @@ impl<'a> Ref<'a> { /// Get the hash of the link target which is stored in the ref object pub fn get_stored_hash(&self) -> Result<String> { - let hasher_name = DefaultHasher::new().hash_name(); - match self.0.get_header().read(&format!("ref.content_hash.{}", hasher_name)[..]) { + self.get_stored_hash_with_hasher(&DefaultHasher::new()) + } + + /// Get the hahs of the link target which is stored in the ref object, which is hashed with a + /// custom Hasher instance. + pub fn get_stored_hash_with_hasher<H: Hasher>(&self, h: &H) -> Result<String> { + match self.0.get_header().read(&format!("ref.content_hash.{}", h.hash_name())[..]) { // content hash stored... Ok(Some(Value::String(s))) => Ok(s), |