From 2f02bf76a40c971b9404aa0913bc8baa7dfde24c Mon Sep 17 00:00:00 2001 From: Vika Date: Wed, 21 Sep 2022 10:44:15 +0300 Subject: Fix some clippy errors --- kittybox-rs/src/indieauth/mod.rs | 3 +++ kittybox-rs/util/src/error.rs | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/kittybox-rs/src/indieauth/mod.rs b/kittybox-rs/src/indieauth/mod.rs index 44cb368..36f207c 100644 --- a/kittybox-rs/src/indieauth/mod.rs +++ b/kittybox-rs/src/indieauth/mod.rs @@ -6,6 +6,7 @@ use axum::{ http::StatusCode, TypedHeader, headers::{Authorization, authorization::Bearer}, Extension }; +#[cfg_attr(not(feature = "webauthn"), allow(unused_imports))] use axum_extra::extract::cookie::{CookieJar, Cookie}; use crate::database::Storage; use kittybox_indieauth::{ @@ -126,6 +127,7 @@ async fn verify_credential( auth: &A, website: &url::Url, credential: Credential, + #[cfg_attr(not(feature = "webauthn"), allow(unused_variables))] challenge_id: Option<&str> ) -> std::io::Result { match credential { @@ -758,6 +760,7 @@ mod tests { match confirmation.authorization_method { Credential::Password(password) => assert_eq!(password.as_str(), "swordfish"), + #[allow(unreachable_patterns)] other => panic!("Incorrect credential: {:?}", other) } assert_eq!(confirmation.request.state.as_ref(), "10101010"); diff --git a/kittybox-rs/util/src/error.rs b/kittybox-rs/util/src/error.rs index 7edf176..1c95020 100644 --- a/kittybox-rs/util/src/error.rs +++ b/kittybox-rs/util/src/error.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize}; use http::StatusCode; use axum_core::response::{Response, IntoResponse}; -#[derive(Serialize, Deserialize, PartialEq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] #[serde(rename_all = "snake_case")] /// Kinds of errors that can happen within a Micropub operation. pub enum ErrorType { @@ -27,7 +27,9 @@ pub enum ErrorType { /// Representation of the Micropub API error. #[derive(Serialize, Deserialize, Debug)] pub struct MicropubError { + /// General kind of an error that occured. pub error: ErrorType, + /// A human-readable error description intended for application developers. // TODO use Cow<'static, str> to save on heap allocations pub error_description: String, } @@ -52,6 +54,7 @@ impl From for MicropubError { } impl MicropubError { + /// Create a new Micropub error. pub fn new(error: ErrorType, error_description: &str) -> Self { Self { error, -- cgit 1.4.1