feat(tvix/nix-compat/nixhash/NixHashWithMode): from_algo_mode_hash
Change-Id: Ieae628fab1926a498ae5c3eb27df1b722e6151d7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9728 Reviewed-by: edef <edef@edef.eu> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
c3446da1c7
commit
8a0fa69c6c
5 changed files with 54 additions and 2 deletions
|
|
@ -65,8 +65,8 @@ impl TryFrom<(HashAlgo, &[u8])> for NixHash {
|
|||
}
|
||||
|
||||
/// Constructs a new [NixHash] by specifying [HashAlgo] and digest.
|
||||
// It can fail if the passed digest length doesn't match what's expected for
|
||||
// the passed algo.
|
||||
/// It can fail if the passed digest length doesn't match what's expected for
|
||||
/// the passed algo.
|
||||
pub fn from_algo_and_digest(algo: HashAlgo, digest: &[u8]) -> Result<NixHash> {
|
||||
if digest.len() != algo.digest_length() {
|
||||
return Err(Error::InvalidEncodedDigestLength(digest.len(), algo));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue