chore: address Rust 1.78 clippy lints (#4545)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Chethan Rao
2024-05-07 16:05:32 +05:30
committed by GitHub
parent 99bbc3982f
commit 2216a88d25
222 changed files with 1138 additions and 1631 deletions

View File

@ -38,14 +38,14 @@ impl NonceSequence {
}
/// Returns the current nonce value as bytes.
fn current(&self) -> [u8; ring::aead::NONCE_LEN] {
let mut nonce = [0_u8; ring::aead::NONCE_LEN];
fn current(&self) -> [u8; aead::NONCE_LEN] {
let mut nonce = [0_u8; aead::NONCE_LEN];
nonce.copy_from_slice(&self.0.to_be_bytes()[Self::SEQUENCE_NUMBER_START_INDEX..]);
nonce
}
/// Constructs a nonce sequence from bytes
fn from_bytes(bytes: [u8; ring::aead::NONCE_LEN]) -> Self {
fn from_bytes(bytes: [u8; aead::NONCE_LEN]) -> Self {
let mut sequence_number = [0_u8; 128 / 8];
sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..].copy_from_slice(&bytes);
let sequence_number = u128::from_be_bytes(sequence_number);
@ -53,16 +53,16 @@ impl NonceSequence {
}
}
impl ring::aead::NonceSequence for NonceSequence {
fn advance(&mut self) -> Result<ring::aead::Nonce, ring::error::Unspecified> {
let mut nonce = [0_u8; ring::aead::NONCE_LEN];
impl aead::NonceSequence for NonceSequence {
fn advance(&mut self) -> Result<aead::Nonce, ring::error::Unspecified> {
let mut nonce = [0_u8; aead::NONCE_LEN];
nonce.copy_from_slice(&self.0.to_be_bytes()[Self::SEQUENCE_NUMBER_START_INDEX..]);
// Increment sequence number
self.0 = self.0.wrapping_add(1);
// Return previous sequence number as bytes
Ok(ring::aead::Nonce::assume_unique_for_key(nonce))
Ok(aead::Nonce::assume_unique_for_key(nonce))
}
}
@ -275,8 +275,8 @@ impl DecodeMessage for GcmAes256 {
.change_context(errors::CryptoError::DecodingFailed)?;
let nonce_sequence = NonceSequence::from_bytes(
<[u8; ring::aead::NONCE_LEN]>::try_from(
msg.get(..ring::aead::NONCE_LEN)
<[u8; aead::NONCE_LEN]>::try_from(
msg.get(..aead::NONCE_LEN)
.ok_or(errors::CryptoError::DecodingFailed)
.attach_printable("Failed to read the nonce form the encrypted ciphertext")?,
)
@ -288,7 +288,7 @@ impl DecodeMessage for GcmAes256 {
let output = binding.as_mut_slice();
let result = key
.open_within(aead::Aad::empty(), output, ring::aead::NONCE_LEN..)
.open_within(aead::Aad::empty(), output, aead::NONCE_LEN..)
.change_context(errors::CryptoError::DecodingFailed)?;
Ok(result.to_vec())

View File

@ -472,13 +472,13 @@ pub trait XmlExt {
///
/// Deserialize an XML string into the specified type `<T>`.
///
fn parse_xml<T>(self) -> Result<T, quick_xml::de::DeError>
fn parse_xml<T>(self) -> Result<T, de::DeError>
where
T: serde::de::DeserializeOwned;
}
impl XmlExt for &str {
fn parse_xml<T>(self) -> Result<T, quick_xml::de::DeError>
fn parse_xml<T>(self) -> Result<T, de::DeError>
where
T: serde::de::DeserializeOwned,
{

View File

@ -38,7 +38,7 @@ pub struct PhoneNumber(Secret<String, PhoneNumberStrategy>);
impl<T> Strategy<T> for PhoneNumberStrategy
where
T: AsRef<str> + std::fmt::Debug,
T: AsRef<str> + fmt::Debug,
{
fn fmt(val: &T, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val_str: &str = val.as_ref();
@ -85,7 +85,7 @@ impl ops::DerefMut for PhoneNumber {
}
}
impl<DB> Queryable<diesel::sql_types::Text, DB> for PhoneNumber
impl<DB> Queryable<sql_types::Text, DB> for PhoneNumber
where
DB: Backend,
Self: FromSql<sql_types::Text, DB>,
@ -210,7 +210,7 @@ pub enum EmailStrategy {}
impl<T> Strategy<T> for EmailStrategy
where
T: AsRef<str> + std::fmt::Debug,
T: AsRef<str> + fmt::Debug,
{
fn fmt(val: &T, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val_str: &str = val.as_ref();
@ -224,7 +224,7 @@ where
#[derive(
serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, Default, AsExpression,
)]
#[diesel(sql_type = diesel::sql_types::Text)]
#[diesel(sql_type = sql_types::Text)]
#[serde(try_from = "String")]
pub struct Email(Secret<String, EmailStrategy>);
@ -262,7 +262,7 @@ impl ops::DerefMut for Email {
}
}
impl<DB> Queryable<diesel::sql_types::Text, DB> for Email
impl<DB> Queryable<sql_types::Text, DB> for Email
where
DB: Backend,
Self: FromSql<sql_types::Text, DB>,
@ -353,7 +353,7 @@ pub enum UpiVpaMaskingStrategy {}
impl<T> Strategy<T> for UpiVpaMaskingStrategy
where
T: AsRef<str> + std::fmt::Debug,
T: AsRef<str> + fmt::Debug,
{
fn fmt(val: &T, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let vpa_str: &str = val.as_ref();

View File

@ -26,6 +26,8 @@ impl<T> StaticCache<T>
where
T: Send,
{
// Cannot have default impl as it cannot be called during instantiation of static item
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
Self {
data: Lazy::new(|| RwLock::new(FxHashMap::default())),