diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-18T10·39+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-10-23T14·57+0000 |
commit | 34fc4637ebbb906d38647ca8a12fdb80cd2baf18 (patch) | |
tree | f735c40fbab6bdbd8027f9e1f75106c070a58807 /tvix/nix-compat/src/derivation/errors.rs | |
parent | 833957b3749d4d31ccb7aeb96a8fb25ebb931e67 (diff) |
refactor(tvix/nix-compat): rename NixHashWithMode -> CAHash r/6871
This specific struct is only used to represent content-addressed paths (in case a Derivation has a fixed-output hash, for example). Rename `Output`'s `hash_with_mode` to `ca_hash`. We now also include `CAHash::Text`, and update the `validate` function of the `Output` struct to reject text hashes there. This allows cleaning up the various output path calculation functions inside nix-compat/src/store_path/utils.rs, as they can now match on the type. `make_type` is renamed to `make_references_string`, `build_regular_ca_path` is renamed to `build_ca_path`, and `build_text_path` has a disclaimer added, because you might not actually want to use it. Change-Id: I674d065f2ed5c804012ddfed56e161ac49d23931 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9814 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/nix-compat/src/derivation/errors.rs')
-rw-r--r-- | tvix/nix-compat/src/derivation/errors.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tvix/nix-compat/src/derivation/errors.rs b/tvix/nix-compat/src/derivation/errors.rs index 8e9e6a121096..305957b10f6d 100644 --- a/tvix/nix-compat/src/derivation/errors.rs +++ b/tvix/nix-compat/src/derivation/errors.rs @@ -1,6 +1,8 @@ -use crate::{nixbase32::Nixbase32DecodeError, store_path}; +use crate::store_path; use thiserror::Error; +use super::CAHash; + /// Errors that can occur during the validation of Derivation structs. #[derive(Debug, Error, PartialEq)] pub enum DerivationError { @@ -50,10 +52,6 @@ pub enum DerivationError { pub enum OutputError { #[error("Invalid output path {0}: {1}")] InvalidOutputPath(String, store_path::Error), - #[error("Invalid hash encoding: {0}")] - InvalidHashEncoding(String, Nixbase32DecodeError), - #[error("Invalid hash algo: {0}")] - InvalidHashAlgo(String), - #[error("Invalid Digest size {0} for algo {1}")] - InvalidDigestSizeForAlgo(usize, String), + #[error("Invalid CAHash: {:?}", .0)] + InvalidCAHash(CAHash), } |