diff options
author | Florian Klink <flokli@flokli.de> | 2024-03-14T12·01+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-03-14T17·38+0000 |
commit | 98e6936301dadc3400cb361a787cac8215c7bab8 (patch) | |
tree | 5e92902ded45cc410b05e4fa31d89fd24fe0746d /tvix/nix-compat | |
parent | 43c851bc841bccc65ffddab7205783c43f25417f (diff) |
refactor(nix-compat/store_path/utils): move helper function in r/7692
This is only used inside this function, in 2 of the match cases. Change-Id: Ib361f5ee0e3b203802f7d05b9a7f332d14bbcf80 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11143 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: John Ericson <git@johnericson.me> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nix-compat')
-rw-r--r-- | tvix/nix-compat/src/store_path/utils.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tvix/nix-compat/src/store_path/utils.rs b/tvix/nix-compat/src/store_path/utils.rs index d054d5955696..d060e0eac925 100644 --- a/tvix/nix-compat/src/store_path/utils.rs +++ b/tvix/nix-compat/src/store_path/utils.rs @@ -66,6 +66,13 @@ pub fn build_ca_path<'a, S: AsRef<str>, I: IntoIterator<Item = S>>( return Err(BuildStorePathError::InvalidReference()); } + /// Helper function, used for the non-sha256 [CAHash::Nar] and all [CAHash::Flat]. + fn fixed_out_digest(prefix: &str, hash: &NixHash) -> [u8; 32] { + Sha256::new_with_prefix(format!("{}:{}:", prefix, hash.to_nix_hex_string())) + .finalize() + .into() + } + let (ty, inner_digest) = match &ca_hash { CAHash::Text(ref digest) => (make_references_string("text", references, false), *digest), CAHash::Nar(NixHash::Sha256(ref digest)) => ( @@ -101,14 +108,6 @@ pub fn build_ca_path<'a, S: AsRef<str>, I: IntoIterator<Item = S>>( .map_err(BuildStorePathError::InvalidStorePath) } -/// Helper function, used in [build_ca_path] for the non-sha256 [CAHash::Nar] -/// and [CAHash::Flat]. -fn fixed_out_digest(prefix: &str, hash: &NixHash) -> [u8; 32] { - Sha256::new_with_prefix(format!("{}:{}:", prefix, hash.to_nix_hex_string())) - .finalize() - .into() -} - /// For given NAR sha256 digest and name, return the new [StorePathRef] this /// would have, or an error, in case the name is invalid. pub fn build_nar_based_store_path<'a>( |