Add variant of Ref::get_stored_hash() to get stored hash with custom hasher
This commit is contained in:
parent
5399b8ca7b
commit
55846168dc
1 changed files with 7 additions and 2 deletions
|
@ -239,8 +239,13 @@ impl<'a> Ref<'a> {
|
||||||
|
|
||||||
/// Get the hash of the link target which is stored in the ref object
|
/// Get the hash of the link target which is stored in the ref object
|
||||||
pub fn get_stored_hash(&self) -> Result<String> {
|
pub fn get_stored_hash(&self) -> Result<String> {
|
||||||
let hasher_name = DefaultHasher::new().hash_name();
|
self.get_stored_hash_with_hasher(&DefaultHasher::new())
|
||||||
match self.0.get_header().read(&format!("ref.content_hash.{}", hasher_name)[..]) {
|
}
|
||||||
|
|
||||||
|
/// 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...
|
// content hash stored...
|
||||||
Ok(Some(Value::String(s))) => Ok(s),
|
Ok(Some(Value::String(s))) => Ok(s),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue