ok/jj
1
0
Fork 0
forked from mirrors/jj

content_hash: make public

I'm going to use `content_hash` in a new commit backend for use in
tests.
This commit is contained in:
Martin von Zweigbergk 2023-09-17 22:22:52 -07:00 committed by Martin von Zweigbergk
parent 9c30d7500b
commit cfffbb6cd7
2 changed files with 5 additions and 1 deletions

View file

@ -1,3 +1,5 @@
//! Portable, stable hashing suitable for identifying values
use blake2::Blake2b512;
use itertools::Itertools as _;
@ -9,9 +11,11 @@ use itertools::Itertools as _;
/// hash a 32-bit little-endian encoding of the ordinal number of the enum
/// variant, then the variant's fields in lexical order.
pub trait ContentHash {
/// Update the hasher state with this object's content
fn hash(&self, state: &mut impl digest::Update);
}
/// The 512-bit BLAKE2b content hash
pub fn blake2b_hash(x: &(impl ContentHash + ?Sized)) -> digest::Output<Blake2b512> {
use digest::Digest;
let mut hasher = Blake2b512::default();

View file

@ -18,7 +18,7 @@
#![deny(unused_must_use)]
#[macro_use]
mod content_hash;
pub mod content_hash;
pub mod backend;
pub mod commit;