From b1ad94cc9a638846de5e2c5b08dbc999b49d11b9 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 27 Oct 2023 13:21:37 +0000 Subject: refactor(nix-compat/store_path): use nixbase32::decode_fixed Change-Id: I81471ee57920aa8fa889fb00c7903cdc570af9c5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9863 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/nix-compat/src/store_path/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tvix') 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); -- cgit 1.4.1