about summary refs log tree commit diff
path: root/tvix/nix-compat/src/store_path
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2023-10-27T13·21+0000
committeredef <edef@edef.eu>2023-10-27T16·08+0000
commitb1ad94cc9a638846de5e2c5b08dbc999b49d11b9 (patch)
treef925b67e54424bb0032e0fefad3fc899a80d68d8 /tvix/nix-compat/src/store_path
parent50aa74a59c106a0e96a9d5c5bf6c0da979d5b33f (diff)
refactor(nix-compat/store_path): use nixbase32::decode_fixed r/6896
Change-Id: I81471ee57920aa8fa889fb00c7903cdc570af9c5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9863
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nix-compat/src/store_path')
-rw-r--r--tvix/nix-compat/src/store_path/mod.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs
index e2c1de8a95c6..faa2280e597d 100644
--- a/tvix/nix-compat/src/store_path/mod.rs
+++ b/tvix/nix-compat/src/store_path/mod.rs
@@ -203,10 +203,8 @@ impl<'a> StorePathRef<'a> {
             Err(Error::InvalidLength)?
         }
 
-        let digest = match nixbase32::decode(&s[..ENCODED_DIGEST_SIZE]) {
-            Ok(decoded) => decoded,
-            Err(decoder_error) => return Err(Error::InvalidHashEncoding(decoder_error)),
-        };
+        let digest = nixbase32::decode_fixed(&s[..ENCODED_DIGEST_SIZE])
+            .map_err(Error::InvalidHashEncoding)?;
 
         if s[ENCODED_DIGEST_SIZE] != b'-' {
             return Err(Error::MissingDash);