about summary refs log tree commit diff
path: root/tvix/nix-compat/src/narinfo
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-11-27T15·17+0200
committerflokli <flokli@flokli.de>2023-11-28T16·08+0000
commite7a86273b1b5e7d818f9bece62c3c44585e76ab5 (patch)
tree15db242d53d7fe10dea4cbfc4cd6fe339a4ffed5 /tvix/nix-compat/src/narinfo
parent7e8719be9146ed370038cb51a87c53ebea388ec3 (diff)
refactor(nix-compat/narinfo/signature): rename Error type r/7082
Just call this Error, we can infer from the package what error this is.

Change-Id: I5df25d2873ec739c49c08804f35562c84c222e06
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10149
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nix-compat/src/narinfo')
-rw-r--r--tvix/nix-compat/src/narinfo/mod.rs2
-rw-r--r--tvix/nix-compat/src/narinfo/signature.rs14
2 files changed, 7 insertions, 9 deletions
diff --git a/tvix/nix-compat/src/narinfo/mod.rs b/tvix/nix-compat/src/narinfo/mod.rs
index 8439403b59e9..df6f3c73c779 100644
--- a/tvix/nix-compat/src/narinfo/mod.rs
+++ b/tvix/nix-compat/src/narinfo/mod.rs
@@ -31,7 +31,7 @@ mod signature;
 
 pub use fingerprint::fingerprint;
 
-pub use signature::{Signature, SignatureError};
+pub use signature::{Error as SignatureError, Signature};
 
 #[derive(Debug)]
 pub struct NarInfo<'a> {
diff --git a/tvix/nix-compat/src/narinfo/signature.rs b/tvix/nix-compat/src/narinfo/signature.rs
index beace4aa8196..9b3d82936cef 100644
--- a/tvix/nix-compat/src/narinfo/signature.rs
+++ b/tvix/nix-compat/src/narinfo/signature.rs
@@ -14,21 +14,19 @@ impl<'a> Signature<'a> {
         Self { name, bytes }
     }
 
-    pub fn parse(input: &'a str) -> Result<Self, SignatureError> {
-        let (name, bytes64) = input
-            .split_once(':')
-            .ok_or(SignatureError::MissingSeparator)?;
+    pub fn parse(input: &'a str) -> Result<Self, Error> {
+        let (name, bytes64) = input.split_once(':').ok_or(Error::MissingSeparator)?;
 
         if name.is_empty()
             || !name
                 .chars()
                 .all(|c| char::is_alphanumeric(c) || c == '-' || c == '.')
         {
-            return Err(SignatureError::InvalidName(name.to_string()));
+            return Err(Error::InvalidName(name.to_string()));
         }
 
         if bytes64.len() != BASE64.encode_len(SIGNATURE_LENGTH) {
-            return Err(SignatureError::InvalidSignatureLen(bytes64.len()));
+            return Err(Error::InvalidSignatureLen(bytes64.len()));
         }
 
         let mut bytes = [0; SIGNATURE_LENGTH];
@@ -37,7 +35,7 @@ impl<'a> Signature<'a> {
             Ok(SIGNATURE_LENGTH) => bytes.copy_from_slice(&buf[..SIGNATURE_LENGTH]),
             Ok(_) => unreachable!(),
             // keeping DecodePartial gets annoying lifetime-wise
-            Err(_) => return Err(SignatureError::DecodeError(input.to_string())),
+            Err(_) => return Err(Error::DecodeError(input.to_string())),
         }
 
         Ok(Signature { name, bytes })
@@ -60,7 +58,7 @@ impl<'a> Signature<'a> {
 }
 
 #[derive(Debug, thiserror::Error)]
-pub enum SignatureError {
+pub enum Error {
     #[error("Invalid name: {0}")]
     InvalidName(String),
     #[error("Missing separator")]