diff --git a/Cargo.toml b/Cargo.toml index b927c5e..f40484a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "jsonwebkey" -version = "0.3.1" +version = "0.3.2" authors = ["Nick Hynes "] description = "JSON Web Key (JWK) (de)serialization, generation, and conversion." readme = "README.md" repository = "https://github.com/nhynes/jwk-rs" +documentation = "http://docs.rs/jsonwebkey/" license = "MIT" edition = "2018" diff --git a/src/lib.rs b/src/lib.rs index cb3750c..8f685f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,8 +65,7 @@ mod key_ops; mod tests; mod utils; -use std::borrow::Cow; -use std::fmt; +use std::{borrow::Cow, fmt}; use generic_array::typenum::U32; use serde::{Deserialize, Serialize}; @@ -193,6 +192,7 @@ impl std::fmt::Display for JsonWebKey { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(tag = "kty")] +#[allow(clippy::upper_case_acronyms)] pub enum Key { /// An elliptic curve, as per [RFC 7518 ยง6.2](https://tools.ietf.org/html/rfc7518#section-6.2). EC { @@ -219,14 +219,17 @@ impl Key { /// Returns true iff this key only contains private components (i.e. a private asymmetric /// key or a symmetric key). pub fn is_private(&self) -> bool { - matches!(self, Self::Symmetric { .. } - | Self::EC { - curve: Curve::P256 { d: Some(_), .. }, - .. - } - | Self::RSA { - private: Some(_), .. - } + matches!( + self, + Self::Symmetric { .. } + | Self::EC { + curve: Curve::P256 { d: Some(_), .. }, + .. + } + | Self::RSA { + private: Some(_), + .. + } ) } @@ -533,6 +536,7 @@ pub enum KeyUse { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[allow(clippy::upper_case_acronyms)] pub enum Algorithm { HS256, RS256, @@ -543,12 +547,12 @@ pub enum Algorithm { const _IMPL_JWT_CONVERSIONS: () = { use jsonwebtoken as jwt; - impl Into for Algorithm { - fn into(self) -> jsonwebtoken::Algorithm { - match self { - Self::HS256 => jwt::Algorithm::HS256, - Self::ES256 => jwt::Algorithm::ES256, - Self::RS256 => jwt::Algorithm::RS256, + impl From for jwt::Algorithm { + fn from(alg: Algorithm) -> Self { + match alg { + Algorithm::HS256 => Self::HS256, + Algorithm::ES256 => Self::ES256, + Algorithm::RS256 => Self::RS256, } } } diff --git a/src/tests.rs b/src/tests.rs index 52190af..5b37da1 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -437,7 +437,10 @@ fn x509_params() { let jwk = JsonWebKey::from_str(X509_JWK_FIXTURE).unwrap(); assert_eq!(jwk.x5.url.unwrap(), "https://example.com/testing.crt"); - assert_eq!(jwk.x5.cert_chain.unwrap(), "---BEGIN CERTIFICATE---..."); + assert_eq!( + jwk.x5.cert_chain.unwrap(), + vec!["---BEGIN CERTIFICATE---..."] + ); assert_eq!( jwk.x5.thumbprint.unwrap(), "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"