mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-04 05:59:48 +08:00 
			
		
		
		
	chore: address Rust 1.72 clippy lints (#2011)
Co-authored-by: Sampras Lopes <lsampras@pm.me>
This commit is contained in:
		@ -1,5 +1,5 @@
 | 
			
		||||
use diesel_models::configs::ConfigUpdateInternal;
 | 
			
		||||
use error_stack::IntoReport;
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
use storage_impl::redis::{
 | 
			
		||||
    cache::{CacheKind, CONFIG_CACHE},
 | 
			
		||||
    kv_store::RedisConnInterface,
 | 
			
		||||
@ -126,8 +126,11 @@ impl ConfigInterface for MockDb {
 | 
			
		||||
        let mut configs = self.configs.lock().await;
 | 
			
		||||
 | 
			
		||||
        let config_new = storage::Config {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: configs.len() as i32,
 | 
			
		||||
            id: configs
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            key: config.key,
 | 
			
		||||
            config: config.config,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
use error_stack::IntoReport;
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::{MockDb, Store};
 | 
			
		||||
use crate::{
 | 
			
		||||
@ -88,8 +88,11 @@ impl ConnectorResponseInterface for MockDb {
 | 
			
		||||
    ) -> CustomResult<storage::ConnectorResponse, errors::StorageError> {
 | 
			
		||||
        let mut connector_response = self.connector_response.lock().await;
 | 
			
		||||
        let response = storage::ConnectorResponse {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: connector_response.len() as i32,
 | 
			
		||||
            id: connector_response
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            payment_id: new.payment_id,
 | 
			
		||||
            merchant_id: new.merchant_id,
 | 
			
		||||
            attempt_id: new.attempt_id,
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
use error_stack::IntoReport;
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::{MockDb, Store};
 | 
			
		||||
use crate::{
 | 
			
		||||
@ -147,8 +147,11 @@ impl DisputeInterface for MockDb {
 | 
			
		||||
        let now = common_utils::date_time::now();
 | 
			
		||||
 | 
			
		||||
        let new_dispute = storage::Dispute {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: locked_disputes.len() as i32,
 | 
			
		||||
            id: locked_disputes
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            dispute_id: dispute.dispute_id,
 | 
			
		||||
            amount: dispute.amount,
 | 
			
		||||
            currency: dispute.currency,
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
use error_stack::IntoReport;
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::{MockDb, Store};
 | 
			
		||||
use crate::{
 | 
			
		||||
@ -52,8 +52,11 @@ impl EventInterface for MockDb {
 | 
			
		||||
        let now = common_utils::date_time::now();
 | 
			
		||||
 | 
			
		||||
        let stored_event = storage::Event {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: locked_events.len() as i32,
 | 
			
		||||
            id: locked_events
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            event_id: event.event_id,
 | 
			
		||||
            event_type: event.event_type,
 | 
			
		||||
            event_class: event.event_class,
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
use error_stack::IntoReport;
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::{MockDb, Store};
 | 
			
		||||
use crate::{
 | 
			
		||||
@ -84,8 +84,11 @@ impl LockerMockUpInterface for MockDb {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let created_locker = storage::LockerMockUp {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: locked_lockers.len() as i32,
 | 
			
		||||
            id: locked_lockers
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            card_id: new.card_id,
 | 
			
		||||
            external_id: new.external_id,
 | 
			
		||||
            card_fingerprint: new.card_fingerprint,
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
use error_stack::IntoReport;
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::{MockDb, Store};
 | 
			
		||||
use crate::{
 | 
			
		||||
@ -221,8 +221,11 @@ impl MandateInterface for MockDb {
 | 
			
		||||
    ) -> CustomResult<storage::Mandate, errors::StorageError> {
 | 
			
		||||
        let mut mandates = self.mandates.lock().await;
 | 
			
		||||
        let mandate = storage::Mandate {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: mandates.len() as i32,
 | 
			
		||||
            id: mandates
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            mandate_id: mandate_new.mandate_id.clone(),
 | 
			
		||||
            customer_id: mandate_new.customer_id,
 | 
			
		||||
            merchant_id: mandate_new.merchant_id,
 | 
			
		||||
 | 
			
		||||
@ -542,8 +542,11 @@ impl MerchantConnectorAccountInterface for MockDb {
 | 
			
		||||
    ) -> CustomResult<domain::MerchantConnectorAccount, errors::StorageError> {
 | 
			
		||||
        let mut accounts = self.merchant_connector_accounts.lock().await;
 | 
			
		||||
        let account = storage::MerchantConnectorAccount {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: accounts.len() as i32,
 | 
			
		||||
            id: accounts
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            merchant_id: t.merchant_id,
 | 
			
		||||
            connector_name: t.connector_name,
 | 
			
		||||
            connector_account_details: t.connector_account_details.into(),
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ use data_models::payments::payment_intent::{
 | 
			
		||||
use data_models::payments::{
 | 
			
		||||
    payment_attempt::PaymentAttempt, payment_intent::PaymentIntentFetchConstraints,
 | 
			
		||||
};
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::MockDb;
 | 
			
		||||
#[cfg(feature = "olap")]
 | 
			
		||||
@ -56,8 +57,11 @@ impl PaymentIntentInterface for MockDb {
 | 
			
		||||
        let mut payment_intents = self.payment_intents.lock().await;
 | 
			
		||||
        let time = common_utils::date_time::now();
 | 
			
		||||
        let payment_intent = PaymentIntent {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: payment_intents.len() as i32,
 | 
			
		||||
            id: payment_intents
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::DataStorageError::MockDbError)?,
 | 
			
		||||
            payment_id: new.payment_id,
 | 
			
		||||
            merchant_id: new.merchant_id,
 | 
			
		||||
            status: new.status,
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
use diesel_models::payment_method::PaymentMethodUpdateInternal;
 | 
			
		||||
use error_stack::IntoReport;
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::{MockDb, Store};
 | 
			
		||||
use crate::{
 | 
			
		||||
@ -134,8 +134,11 @@ impl PaymentMethodInterface for MockDb {
 | 
			
		||||
        let mut payment_methods = self.payment_methods.lock().await;
 | 
			
		||||
 | 
			
		||||
        let payment_method = storage::PaymentMethod {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: payment_methods.len() as i32,
 | 
			
		||||
            id: payment_methods
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            customer_id: payment_method_new.customer_id,
 | 
			
		||||
            merchant_id: payment_method_new.merchant_id,
 | 
			
		||||
            payment_method_id: payment_method_new.payment_method_id,
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
use std::collections::HashSet;
 | 
			
		||||
 | 
			
		||||
use diesel_models::{errors::DatabaseError, refund::RefundUpdateInternal};
 | 
			
		||||
use error_stack::{IntoReport, ResultExt};
 | 
			
		||||
 | 
			
		||||
use super::MockDb;
 | 
			
		||||
use crate::{
 | 
			
		||||
@ -735,8 +736,11 @@ impl RefundInterface for MockDb {
 | 
			
		||||
        let current_time = common_utils::date_time::now();
 | 
			
		||||
 | 
			
		||||
        let refund = storage_types::Refund {
 | 
			
		||||
            #[allow(clippy::as_conversions)]
 | 
			
		||||
            id: refunds.len() as i32,
 | 
			
		||||
            id: refunds
 | 
			
		||||
                .len()
 | 
			
		||||
                .try_into()
 | 
			
		||||
                .into_report()
 | 
			
		||||
                .change_context(errors::StorageError::MockDbError)?,
 | 
			
		||||
            internal_reference_id: new.internal_reference_id,
 | 
			
		||||
            refund_id: new.refund_id,
 | 
			
		||||
            payment_id: new.payment_id,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user