diff --git a/Cargo.toml b/Cargo.toml index a97f4fa..9e7c673 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,12 +10,12 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -failure = "0.1" num-bigint = "0.2" num-bigint-dig = "0.4" num-traits = "0.2" pem = "0.4" rsa = "0.1.3" +thiserror = "1.0.9" yasna = { version = "0.3", features = ["num-bigint"] } [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index a9891eb..24dfa9a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use failure::Fail; +use thiserror::Error; use num_bigint_dig::{BigInt, BigUint, Sign}; mod private; @@ -17,21 +17,21 @@ pub trait KeyExt { Self: Sized; } -#[derive(Debug, Fail)] +#[derive(Debug, Error)] pub enum KeyError { - #[fail(display = "Invalid key kind supplied")] + #[error("Invalid key kind supplied")] Kind, - #[fail(display = "Key not PEM-formatted")] + #[error("Key not PEM-formatted")] Pem, - #[fail(display = "Error parsing key, {}", _0)] - Parse(#[cause] yasna::ASN1Error), + #[error("Error parsing key, {}", .0)] + Parse(#[from] yasna::ASN1Error), - #[fail(display = "Constructed key is invalid")] + #[error("Constructed key is invalid")] Validate, - #[fail(display = "Could not serialize key")] + #[error("Could not serialize key")] Serialize, } @@ -56,12 +56,6 @@ fn sign_from_dig(sign: Sign) -> num_bigint::Sign { } } -impl From for KeyError { - fn from(e: yasna::ASN1Error) -> Self { - KeyError::Parse(e) - } -} - #[cfg(test)] mod tests { use crate::KeyExt;