diff options
author | Jürgen Hahn <mail.jhahn@gmail.com> | 2022-12-30T15·40+0100 |
---|---|---|
committer | jrhahn <mail.jhahn@gmail.com> | 2022-12-30T16·02+0000 |
commit | 60bdf619a38f05f8a8815feffc562b0e5c40143f (patch) | |
tree | ecf7419331c73bc4e279a2f2b92aafcb99126216 /tvix | |
parent | 58f5ff2c173b6c64e3ffb1d2cd4d840e0dcf38c3 (diff) |
feat(tvix/store): refactor digest conversion r/5555
This refactors how the original digest type (Vec<u8>) is converted to [u8; PATH_HASH_SIZE]. Change-Id: I9441470a3a199620fcf328f2b7c890ca6ae93bde Reviewed-on: https://cl.tvl.fyi/c/depot/+/7710 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/Cargo.lock | 2 | ||||
-rw-r--r-- | tvix/store/src/nixpath.rs | 6 |
2 files changed, 2 insertions, 6 deletions
diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock index 35aeb3aa4f4c..ec6668a2d627 100644 --- a/tvix/Cargo.lock +++ b/tvix/Cargo.lock @@ -2145,8 +2145,8 @@ version = "0.1.0" dependencies = [ "anyhow", "blake3", - "data-encoding", "clap 4.0.32", + "data-encoding", "lazy_static", "prost", "prost-build", diff --git a/tvix/store/src/nixpath.rs b/tvix/store/src/nixpath.rs index 8232e3241e11..44350803eafa 100644 --- a/tvix/store/src/nixpath.rs +++ b/tvix/store/src/nixpath.rs @@ -49,13 +49,9 @@ impl NixPath { NixPath::validate_characters(&s[name_offset..])?; - // copy the digest:Vec<u8> to a [u8; PATH_HASH_SIZE] - let mut buffer: [u8; PATH_HASH_SIZE] = [0; PATH_HASH_SIZE]; - buffer[..PATH_HASH_SIZE].copy_from_slice(&digest[..PATH_HASH_SIZE]); - Ok(NixPath { name: s[name_offset..].to_string(), - digest: buffer, + digest: digest.try_into().expect("size is known"), }) } |