From 6fe2b6736be36e6fe56dfe6784a1349f0ab4d157 Mon Sep 17 00:00:00 2001 From: Patrik Stas Date: Mon, 13 Nov 2023 15:34:32 +0100 Subject: [PATCH] Fixes, cleanups Signed-off-by: Patrik Stas --- aries_vcx/src/lib.rs | 1 + aries_vcx/tests/test_did_exchange.rs | 1 - aries_vcx/tests/utils/mod.rs | 2 - aries_vcx/tests/utils/test_macros.rs | 70 ---------------------------- 4 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 aries_vcx/tests/utils/test_macros.rs diff --git a/aries_vcx/src/lib.rs b/aries_vcx/src/lib.rs index b16f42358d..27f586e805 100644 --- a/aries_vcx/src/lib.rs +++ b/aries_vcx/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::result_large_err)] #![allow(clippy::large_enum_variant)] #![allow(clippy::diverging_sub_expression)] //this is needed for some large json macro invocations diff --git a/aries_vcx/tests/test_did_exchange.rs b/aries_vcx/tests/test_did_exchange.rs index 91082d2b1a..f090429b18 100644 --- a/aries_vcx/tests/test_did_exchange.rs +++ b/aries_vcx/tests/test_did_exchange.rs @@ -1,4 +1,3 @@ -#[macro_use] extern crate log; use std::sync::Arc; diff --git a/aries_vcx/tests/utils/mod.rs b/aries_vcx/tests/utils/mod.rs index ee9c8e0e90..fb9ff8cd11 100644 --- a/aries_vcx/tests/utils/mod.rs +++ b/aries_vcx/tests/utils/mod.rs @@ -1,7 +1,5 @@ pub mod scenarios; pub mod test_agent; -pub mod test_macros; - use std::time::Duration; use aries_vcx::{ diff --git a/aries_vcx/tests/utils/test_macros.rs b/aries_vcx/tests/utils/test_macros.rs deleted file mode 100644 index a2a2211fcb..0000000000 --- a/aries_vcx/tests/utils/test_macros.rs +++ /dev/null @@ -1,70 +0,0 @@ -use std::fmt; - -use aries_vcx::handlers::util::Status; - -macro_rules! enum_number { - ($name:ident { $($variant:ident = $value:expr, )* }) => { - #[derive(Clone, Copy, Debug, Eq, PartialEq)] - pub enum $name { - $($variant = $value,)* - } - - impl ::serde::Serialize for $name { - fn serialize(&self, serializer: S) -> Result - where S: ::serde::Serializer - { - // Serialize the enum as a u64. - serializer.serialize_u64(*self as u64) - } - } - - impl<'de> ::serde::Deserialize<'de> for $name { - fn deserialize(deserializer: D) -> Result - where D: ::serde::Deserializer<'de> - { - struct Visitor; - - impl<'de> ::serde::de::Visitor<'de> for Visitor { - type Value = $name; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("positive integer") - } - - fn visit_u64(self, value: u64) -> Result<$name, E> - where E: ::serde::de::Error - { - // Rust does not come with a simple way of converting a - // number to an enum, so use a big `match`. - match value { - $( $value => Ok($name::$variant), )* - _ => Err(E::custom( - format!("unknown {} value: {}", - stringify!($name), value))), - } - } - } - - // Deserialize the enum from a u64. - deserializer.deserialize_u64(Visitor) - } - } - } -} - -enum_number!(ProofStateType -{ - ProofUndefined = 0, - ProofValidated = 1, - ProofInvalid = 2, -}); - -impl From for ProofStateType { - fn from(state: Status) -> Self { - match state { - Status::Success => ProofStateType::ProofValidated, - Status::Failed(_) => ProofStateType::ProofInvalid, - _ => ProofStateType::ProofUndefined, - } - } -}