diff options
author | Florian Klink <flokli@flokli.de> | 2023-11-27T15·17+0200 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-11-28T16·08+0000 |
commit | e7a86273b1b5e7d818f9bece62c3c44585e76ab5 (patch) | |
tree | 15db242d53d7fe10dea4cbfc4cd6fe339a4ffed5 /tvix/nix-compat/src/narinfo/signature.rs | |
parent | 7e8719be9146ed370038cb51a87c53ebea388ec3 (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/signature.rs')
-rw-r--r-- | tvix/nix-compat/src/narinfo/signature.rs | 14 |
1 files changed, 6 insertions, 8 deletions
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")] |