From 60bdf619a38f05f8a8815feffc562b0e5c40143f Mon Sep 17 00:00:00 2001 From: Jürgen Hahn Date: Fri, 30 Dec 2022 16:40:58 +0100 Subject: feat(tvix/store): refactor digest conversion This refactors how the original digest type (Vec) 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 --- tvix/Cargo.lock | 2 +- 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 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"), }) } -- cgit 1.4.1