text
stringlengths
70
351k
source
stringclasses
4 values
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src use crate::{ crypto::encryption_manager::encryption_interface::Encryption, error::{self, ContainerError}, }; use josekit::{jwe, jws}; pub fn encrypt_jwe( payload: &[u8], public_key: impl AsRef<[u8]>, alg: jwe::alg::rsaes::RsaesJweAlgorithm, ) -> Result<String, error::CryptoError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src use crate::{ crypto::encryption_manager::encryption_interface::Encryption, error::{self, ContainerError}, }; use josekit::{jwe, jws}; pub fn jws_sign_payload( payload: &[u8], private_key: impl AsRef<[u8]>, ) -> Result<String, error::CryptoError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src use crate::{ crypto::encryption_manager::encryption_interface::Encryption, error::{self, ContainerError}, }; use josekit::{jwe, jws}; fn decrypt(&self, input: JweBody) -> Self::ReturnType<'_, Vec<u8>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src use crate::{ crypto::encryption_manager::encryption_interface::Encryption, error::{self, ContainerError}, }; fn encrypt(&self, input: Vec<u8>) -> Self::ReturnType<'_, JweBody> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src use crate::{ crypto::encryption_manager::encryption_interface::Encryption, error::{self, ContainerError}, }; pub fn get_dotted_jwe(self) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src fn from_str(input: &str) -> Option<Self> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src use crate::{ crypto::encryption_manager::encryption_interface::Encryption, error::{self, ContainerError}, }; pub fn get_dotted_jws(self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src fn from_dotted_str(input: &str) -> Option<Self> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/encryption_manager/managers/jw.rs | crate: src use josekit::{jwe, jws}; pub fn new( private_key: String, public_key: String, enc_algo: jwe::alg::rsaes::RsaesJweAlgorithm, dec_algo: jwe::alg::rsaes::RsaesJweAlgorithm, ) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/internal_keymanager.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; use crate::{ app::TenantAppState, crypto::{ encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, keymanager::CryptoOperationsManager, }, error::{self, ContainerError}, storage::MerchantInterface, }; async fn decrypt_data( &self, _tenant_app_state: &TenantAppState, encrypted_data: Secret<Vec<u8>>, ) -> Result<StrongSecret<Vec<u8>>, ContainerError<error::ApiError>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/internal_keymanager.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; use crate::{ app::TenantAppState, crypto::{ encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, keymanager::CryptoOperationsManager, }, error::{self, ContainerError}, storage::MerchantInterface, }; async fn encrypt_data( &self, _tenant_app_state: &TenantAppState, decryted_data: StrongSecret<Vec<u8>>, ) -> Result<Secret<Vec<u8>>, ContainerError<error::ApiError>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/internal_keymanager.rs | crate: src use crate::{ app::TenantAppState, crypto::{ encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, keymanager::CryptoOperationsManager, }, error::{self, ContainerError}, storage::MerchantInterface, }; fn get_inner(&self) -> &GcmAes256 { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/internal_keymanager.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; use crate::{ app::TenantAppState, crypto::{ encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, keymanager::CryptoOperationsManager, }, error::{self, ContainerError}, storage::MerchantInterface, }; fn from_secret_key(key: Secret<Vec<u8>>) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/internal_keymanager.rs | crate: src use crate::{ app::TenantAppState, crypto::{ encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, keymanager::CryptoOperationsManager, }, error::{self, ContainerError}, storage::MerchantInterface, }; async fn find_or_create_entity( &self, tenant_app_state: &TenantAppState, entity_id: String, ) -> Result<Box<dyn CryptoOperationsManager>, ContainerError<error::ApiError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use serde::{ de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; pub fn get_identifier(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use serde::{ de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; fn visit_str<E>(self, value: &str) -> Result<DecryptedData, E> where E: de::Error, { let dec_data = crypto::consts::BASE64_ENGINE.decode(value).map_err(|err| { let err = err.to_string(); E::invalid_value(Unexpected::Str(value), &err.as_str()) })?; Ok(DecryptedData(dec_data.into())) }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; use serde::{ de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; pub fn from_value<T>( data: &StrongSecret<T>, ) -> Result<Self, error::ContainerError<error::ApiError>> where T: Serialize + masking::DefaultIsZeroes, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; use serde::{ de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; pub fn inner(self) -> StrongSecret<Vec<u8>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; pub fn from_secret(data: StrongSecret<Vec<u8>>) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use serde::{ de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; use std::fmt; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("string of the format {version}:{base64_encoded_data}'") }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use serde::{ de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; pub fn serialize_encryption_data<S>( encrypted_data: &EncryptedData, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src fn from(value: EncryptedData) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; use serde::{ de::{self, Unexpected, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; pub fn inner(self) -> Secret<Vec<u8>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; pub fn from_secret(data: Secret<Vec<u8>>) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; pub fn create_request(key_identifier: String, data: Secret<Vec<u8>>) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; use masking::{ExposeInterface, PeekInterface, Secret, StrongSecret}; pub fn create_request( key_identifier: String, data: StrongSecret<Vec<u8>>, ) -> Result<Self, error::ContainerError<error::ApiError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; pub fn create_request(key: Vec<u8>) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/crypto/keymanager/external_keymanager/types.rs | crate: src use crate::{ crypto::{self, consts::BASE64_ENGINE}, error::{self, ResultContainerExt}, storage::{consts, types::Encrypted, utils}, }; pub fn create_request() -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/utils.rs | crate: src /// Generate UUID v4 as strings to be used in storage layer pub fn generate_uuid() -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/utils.rs | crate: src use crate::storage::consts; pub fn generate_nano_id(id_length: usize) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; pub fn implement_cache(config: &'_ crate::config::Cache) -> impl Fn(T) -> Self + '_ { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; pub async fn cache_data<U>( &self, key: <T as super::Cacheable<U>>::Key, value: <T as super::Cacheable<U>>::Value, ) where T: super::Cacheable<U>, Self: GetCache<T, U>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use std::sync::Arc; use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; pub async fn lookup<U>( &self, key: <T as super::Cacheable<U>>::Key, ) -> Option<<T as super::Cacheable<U>>::Value> where T: super::Cacheable<U>, Self: GetCache<T, U>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; fn get_cache(&self) -> &Cache<T, types::Entity> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; fn get_cache(&self) -> &Cache<T, types::Fingerprint> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; fn get_cache(&self) -> &Cache<T, types::HashTable> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; fn get_cache(&self) -> &Cache<T, types::Merchant> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching.rs | crate: src use std::sync::Arc; use super::types; pub(super) type Cache<T, U> = moka::future::Cache<<T as super::Cacheable<U>>::Key, Arc<<T as super::Cacheable<U>>::Value>>; fn new_cache<T, U>(config: &crate::config::Cache, name: &str) -> Cache<T, U> where T: super::Cacheable<U>, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch-card-vault/src/storage/caching/fingerprint.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret}; use crate::{ error::ContainerError, storage::{self, types}, }; async fn get_or_insert_fingerprint( &self, data: Secret<String>, key: Secret<String>, ) -> Result<types::Fingerprint, ContainerError<Self::Error>> { let output = self.inner.get_or_insert_fingerprint(data, key).await?; self.cache_data::<types::Fingerprint>( output.fingerprint_hash.clone().expose(), output.clone(), ) .await; Ok(output) }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching/fingerprint.rs | crate: src use masking::{ExposeInterface, PeekInterface, Secret}; use crate::{ error::ContainerError, storage::{self, types}, }; async fn find_by_fingerprint_hash( &self, fingerprint_hash: Secret<Vec<u8>>, ) -> Result<Option<types::Fingerprint>, ContainerError<Self::Error>> { { Some(data) => Ok(Some(data)),<|fim_suffix|> <|fim_middle|> None => { let result = self .inner .find_by_fingerprint_hash(fingerprint_hash) .await?; if let Some(ref fingerprint) = result { self.cache_data::<types::Fingerprint>(key, fingerprint.clone()) .await; } Ok(result) } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching/merchant.rs | crate: src use crate::{ error::{ContainerError, NotFoundError}, storage::{self, types}, }; async fn insert_merchant( &self, new: types::MerchantNew<'_>, key: &Self::Algorithm, ) -> Result<types::Merchant, ContainerError<Self::Error>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching/merchant.rs | crate: src use crate::crypto::encryption_manager::managers::aes; use crate::{ error::{ContainerError, NotFoundError}, storage::{self, types}, }; async fn find_or_create_by_merchant_id( &self, merchant_id: &str, key: &Self::Algorithm, ) -> Result<types::Merchant, ContainerError<Self::Error>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/storage/caching/merchant.rs | crate: src use crate::{ error::{ContainerError, NotFoundError}, storage::{self, types}, }; async fn find_by_merchant_id( &self, merchant_id: &str, key: &Self::Algorithm, ) -> Result<types::Merchant, ContainerError<Self::Error>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/error/custom_error.rs | crate: src fn is_not_found(&self) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch-card-vault/src/error/custom_error.rs | crate: src fn is_not_found(&self) -> bool { matches!(self.error.current_context(), MerchantDBError::NotFoundError) }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/health.rs | crate: src use crate::tenant::GlobalAppState; use crate::{crypto::keymanager, logger}; use axum::{routing::get, Json}; use crate::{custom_extractors::TenantStateResolver, error, storage::TestInterface}; /// '/health/diagnostics` API handler` pub async fn diagnostics(TenantStateResolver(state): TenantStateResolver) -> Json<Diagnostics> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/health.rs | crate: src use crate::tenant::GlobalAppState; use crate::{crypto::keymanager, logger}; use axum::{routing::get, Json}; use crate::{custom_extractors::TenantStateResolver, error, storage::TestInterface}; /// '/health` API handler` pub async fn health() -> Json<HealthRespPayload> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/health.rs | crate: src use std::sync::Arc; use crate::tenant::GlobalAppState; use axum::{routing::get, Json}; /// /// Function for registering routes that is specifically handling the health apis /// pub fn serve() -> axum::Router<Arc<GlobalAppState>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/tenant.rs | crate: src pub fn serve<S>() -> axum::Router<S> where S: Send + Sync + Clone + 'static, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_migration.rs | crate: src use crate::{ app::TenantAppState, crypto::{ consts::BASE64_ENGINE, encryption_manager::managers::aes::GcmAes256, keymanager::external_keymanager::{ self, types::{DataKeyTransferRequest, Identifier}, }, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{ consts, types::{Entity, Merchant}, utils, EntityInterface, MerchantInterface, }, }; pub async fn migrate_key_to_key_manager( state: &TenantAppState, entity_id: &str, request_body: DataKeyTransferRequest, ) -> Result<Entity, ContainerError<error::KeyManagerError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_migration.rs | crate: src use crate::{ app::TenantAppState, crypto::{ consts::BASE64_ENGINE, encryption_manager::managers::aes::GcmAes256, keymanager::external_keymanager::{ self, types::{DataKeyTransferRequest, Identifier}, }, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{ consts, types::{Entity, Merchant}, utils, EntityInterface, MerchantInterface, }, }; pub async fn send_request_to_key_service_for_merchant( state: &TenantAppState, keys: Vec<Merchant>, ) -> Result<usize, ContainerError<error::ApiError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_migration.rs | crate: src use axum::Json; use crate::{ app::TenantAppState, crypto::{ consts::BASE64_ENGINE, encryption_manager::managers::aes::GcmAes256, keymanager::external_keymanager::{ self, types::{DataKeyTransferRequest, Identifier}, }, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{ consts, types::{Entity, Merchant}, utils, EntityInterface, MerchantInterface, }, }; pub async fn transfer_keys( TenantStateResolver(tenant_app_state): TenantStateResolver, Json(request): Json<MerchantKeyTransferRequest>, ) -> Result<Json<TransferKeyResponse>, ContainerError<error::ApiError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data.rs | crate: src use axum::{routing::post, Json}; use axum::{error_handling::HandleErrorLayer, response::IntoResponse}; use crate::{ crypto::{ hash_manager::managers::sha::Sha512, keymanager::{self, KeyProvider}, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{FingerprintInterface, HashInterface, LockerInterface}, tenant::GlobalAppState, utils, }; use self::types::Validation; /// `/data/retrieve` handling the requirement of retrieving data pub async fn retrieve_card( TenantStateResolver(tenant_app_state): TenantStateResolver, Json(request): Json<types::RetrieveCardRequest>, ) -> Result<Json<types::RetrieveCardResponse>, ContainerError<error::ApiError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data.rs | crate: src use axum::{routing::post, Json}; use axum::{error_handling::HandleErrorLayer, response::IntoResponse}; use crate::{ crypto::{ hash_manager::managers::sha::Sha512, keymanager::{self, KeyProvider}, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{FingerprintInterface, HashInterface, LockerInterface}, tenant::GlobalAppState, utils, }; use self::types::Validation; /// `/data/add` handling the requirement of storing data pub async fn add_card( TenantStateResolver(tenant_app_state): TenantStateResolver, Json(request): Json<types::StoreCardRequest>, ) -> Result<Json<types::StoreCardResponse>, ContainerError<error::ApiError>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data.rs | crate: src use std::sync::Arc; use axum::{routing::post, Json}; use axum::{error_handling::HandleErrorLayer, response::IntoResponse}; use crate::{ crypto::{ hash_manager::managers::sha::Sha512, keymanager::{self, KeyProvider}, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{FingerprintInterface, HashInterface, LockerInterface}, tenant::GlobalAppState, utils, }; pub fn serve( #[cfg(feature = "limit")] global_app_state: Arc<GlobalAppState>, ) -> axum::Router<Arc<GlobalAppState>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data.rs | crate: src use axum::{routing::post, Json}; use axum::{error_handling::HandleErrorLayer, response::IntoResponse}; use crate::{ crypto::{ hash_manager::managers::sha::Sha512, keymanager::{self, KeyProvider}, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{FingerprintInterface, HashInterface, LockerInterface}, tenant::GlobalAppState, utils, }; use self::types::Validation; /// `/cards/fingerprint` handling the creation and retrieval of card fingerprint pub async fn get_or_insert_fingerprint( TenantStateResolver(tenant_app_state): TenantStateResolver, Json(request): Json<types::FingerprintRequest>, ) -> Result<Json<types::FingerprintResponse>, ContainerError<error::ApiError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data.rs | crate: src use axum::{routing::post, Json}; use axum::{error_handling::HandleErrorLayer, response::IntoResponse}; use crate::{ crypto::{ hash_manager::managers::sha::Sha512, keymanager::{self, KeyProvider}, }, custom_extractors::TenantStateResolver, error::{self, ContainerError, ResultContainerExt}, logger, storage::{FingerprintInterface, HashInterface, LockerInterface}, tenant::GlobalAppState, utils, }; use self::types::Validation; /// `/data/delete` handling the requirement of deleting data pub async fn delete_card( TenantStateResolver(tenant_app_state): TenantStateResolver, Json(request): Json<types::DeleteCardRequest>, ) -> Result<Json<types::DeleteCardResponse>, ContainerError<error::ApiError>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data.rs | crate: src use axum::{routing::post, Json}; use axum::{error_handling::HandleErrorLayer, response::IntoResponse}; async fn ratelimit_err_handler(_: axum::BoxError) -> impl IntoResponse { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_custodian.rs | crate: src use std::sync::Arc; use axum::{extract::State, routing::post, Json}; use crate::{ app::TenantAppState, config::TenantConfig, crypto::encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, custom_extractors::TenantId, error::{self, ResultContainerExt}, logger, tenant::GlobalAppState, }; /// Handler for `/custodian/decrypt` pub async fn decrypt( State(global_app_state): State<Arc<GlobalAppState>>, TenantId(tenant_id): TenantId, ) -> Result<Json<CustodianRespPayload>, error::ContainerError<error::ApiError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_custodian.rs | crate: src use crate::{ app::TenantAppState, config::TenantConfig, crypto::encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, custom_extractors::TenantId, error::{self, ResultContainerExt}, logger, tenant::GlobalAppState, }; async fn aes_decrypt_custodian_key( tenant_config: &mut TenantConfig, inner_key1: &str, inner_key2: &str, ) -> Result<(), error::ContainerError<error::ApiError>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_custodian.rs | crate: src use std::sync::Arc; use axum::{extract::State, routing::post, Json}; use crate::{ app::TenantAppState, config::TenantConfig, crypto::encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, custom_extractors::TenantId, error::{self, ResultContainerExt}, logger, tenant::GlobalAppState, }; /// Handler for `/custodian/key2` pub async fn key2( State(global_app_state): State<Arc<GlobalAppState>>, TenantId(tenant_id): TenantId, Json(payload): Json<CustodianReqPayload>, ) -> Json<CustodianRespPayload> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_custodian.rs | crate: src use std::sync::Arc; use axum::{extract::State, routing::post, Json}; use crate::{ app::TenantAppState, config::TenantConfig, crypto::encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, custom_extractors::TenantId, error::{self, ResultContainerExt}, logger, tenant::GlobalAppState, }; /// Handler for `/custodian/key1` pub async fn key1( State(global_app_state): State<Arc<GlobalAppState>>, TenantId(tenant_id): TenantId, Json(payload): Json<CustodianReqPayload>, ) -> Json<CustodianRespPayload> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_custodian.rs | crate: src use std::sync::Arc; use axum::{extract::State, routing::post, Json}; use crate::{ app::TenantAppState, config::TenantConfig, crypto::encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, custom_extractors::TenantId, error::{self, ResultContainerExt}, logger, tenant::GlobalAppState, }; /// /// Function for registering routes that is specifically handling the custodian apis /// pub fn serve() -> axum::Router<Arc<GlobalAppState>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/key_custodian.rs | crate: src use crate::{ app::TenantAppState, config::TenantConfig, crypto::encryption_manager::{encryption_interface::Encryption, managers::aes::GcmAes256}, custom_extractors::TenantId, error::{self, ResultContainerExt}, logger, tenant::GlobalAppState, }; fn key_validation<'de, D>(deserializer: D) -> Result<String, D::Error> where D: serde::Deserializer<'de>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/routes_v2/data/types.rs | crate: src use masking::{Secret, StrongSecret}; use crate::{ error, routes::data::types::{SecretDataManager, Ttl, Validation}, storage::{storage_v2::types::Vault, types::Encryptable}, }; fn set_decrypted_data(mut self, decrypted_data: StrongSecret<Vec<u8>>) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data/types.rs | crate: src use masking::{Secret, StrongSecret}; use crate::{ error, storage::{ self, types::{Encryptable, Locker}, }, utils, }; fn get_encrypted_inner_value(&self) -> Option<Secret<Vec<u8>>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-card-vault/src/routes/data/types.rs | crate: src use crate::{ error, storage::{ self, types::{Encryptable, Locker}, }, utils, }; fn validate(&self) -> Result<(), Self::Error> { { Data::EncData { .. } => Ok(()),<|fim_suffix|> <|fim_middle|> Data::Card { card } => card.card_number.validate(), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch-encryption-service/src/core/crypto/decryption.rs | crate: src use crate::{ env::observability as logger, errors::{self, SwitchError}, metrics, multitenancy::TenantState, types::{requests::DecryptionRequest, response::DecryptionResponse}, }; use opentelemetry::KeyValue; use super::custodian::Custodian; pub(super) async fn decryption( state: TenantState, custodian: Custodian, req: DecryptionRequest, ) -> errors::CustomResult<DecryptionResponse, errors::ApplicationErrorResponse> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch-encryption-service/src/core/datakey/rotate.rs | crate: src use crate::{ core::{crypto::KeyEncrypter, custodian::Custodian}, env::observability as logger, errors::{self, SwitchError}, multitenancy::TenantState, storage::dek::DataKeyStorageInterface, types::{requests::RotateDataKeyRequest, response::DataKeyCreateResponse, Key}, }; pub async fn generate_and_rotate_data_key( state: TenantState, custodian: Custodian, req: RotateDataKeyRequest, ) -> errors::CustomResult<DataKeyCreateResponse, errors::ApplicationErrorResponse> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch-encryption-service/src/storage/adapter/postgres.rs | crate: src use crate::storage::{adapter::PostgreSQL, errors, Config, Connection, DbState}; use diesel::ConnectionError; use diesel_async::pooled_connection::{bb8::Pool, AsyncDieselConnectionManager, ManagerConfig}; use diesel_async::AsyncPgConnection; async fn from_config(config: &Config, schema: &str) -> Self { let database = &config.database; let password = database.password.expose(config).await; let database_url = format!( "postgres://{}:{}@{}:{}/{}?application_name={}&options=-c search_path%3D{}", database.user.peek(), password.peek(), database.host, database.port, database.dbname.peek(), schema, schema ); #[cfg(not(feature = "postgres_ssl"))] let mgr_config = ManagerConfig::default(); #[cfg(feature = "postgres_ssl")] let mut mgr_config = ManagerConfig::default(); #[cfg(feature = "postgres_ssl")] if database.enable_ssl == Some(true) { let root_ca = database .root_ca .clone() .expect("Failed to load db server root cert from the config") .expose(config) .await; mgr_config.custom_setup = Box::new(move |config: &str| { Box::pin({ let root_ca = root_ca.clone(); async move { let mut root_certificate = rustls::RootCertStore::empty(); for cert in rustls_pemfile::certs(&mut root_ca.peek().as_ref()) { root_certificate .add(cert.expect("Failed to load db server root cert")) .expect("Failed to add cert to RootCertStore"); } let rustls_config = rustls::ClientConfig::builder() .with_root_certificates(root_certificate) .with_no_client_auth(); let tls = tokio_postgres_rustls::MakeRustlsConnect::new(rustls_config); let (client, conn) = tokio_postgres::connect(config, tls) .await .map_err(|e| ConnectionError::BadConnection(e.to_string()))?; AsyncPgConnection::try_from_client_and_connection(client, conn).await } }) }); } let mgr = AsyncDieselConnectionManager::<AsyncPgConnection>::new_with_config( database_url, mgr_config, ); let pool = Pool::builder() .max_size(database.pool_size.unwrap_or(10)) .min_idle(database.min_idle) .build(mgr) .await .expect("Failed to establish pool connection"); Self { _adapter: std::marker::PhantomData, pool, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/refunds.rs | crate: hyperswitch_domain_models use crate::errors; fn try_from( (value, auth_profile_id_list): ( api_models::refunds::RefundListRequest, Option<Vec<common_utils::id_type::ProfileId>>, ), ) -> Result<Self, Self::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/disputes.rs | crate: hyperswitch_domain_models use crate::errors; fn try_from( (value, auth_profile_id_list): ( api_models::disputes::DisputeListGetConstraints, Option<Vec<common_utils::id_type::ProfileId>>, ), ) -> Result<Self, Self::Error> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/merchant_key_store.rs | crate: hyperswitch_domain_models use common_utils::{ crypto::Encryptable, custom_serde, date_time, errors::{CustomResult, ValidationError}, type_name, types::keymanager::{self, KeyManagerState}, }; use masking::{PeekInterface, Secret}; use crate::type_encryption::{crypto_operation, CryptoOperation}; async fn convert_back( state: &KeyManagerState, item: Self::DstType, key: &Secret<Vec<u8>>, _key_manager_identifier: keymanager::Identifier, ) -> CustomResult<Self, ValidationError> where Self: Sized, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payouts/payouts.rs | crate: hyperswitch_domain_models fn from(payout_update: PayoutsUpdate) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs | crate: hyperswitch_domain_models fn from(payout_update: PayoutAttemptUpdate) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/test_utils/tests/connectors/bluesnap_ui.rs | crate: test_utils | connector: bluesnap_ui async fn should_make_3ds_payment(driver: WebDriver) -> Result<(), WebDriverError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/test_utils/src/main.rs | crate: test_utils use std::process::{exit, Command}; use anyhow::Result; use test_utils::newman_runner; fn main() -> Result<()> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/diesel_models/src/payouts.rs | crate: diesel_models use serde::{self, Deserialize, Serialize}; pub fn apply_changeset(self, source: Payouts) -> Payouts { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/diesel_models/src/fraud_check.rs | crate: diesel_models fn from(fraud_check_update: FraudCheckUpdate) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/diesel_models/src/user.rs | crate: diesel_models use common_utils::{encryption::Encryption, pii}; fn from(user_update: UserUpdate) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/diesel_models/src/gsm.rs | crate: diesel_models use common_utils::{ custom_serde, events::{ApiEventMetric, ApiEventsType}, }; fn from(value: GatewayStatusMappingUpdate) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/diesel_models/src/payout_attempt.rs | crate: diesel_models use serde::{self, Deserialize, Serialize}; pub fn apply_changeset(self, source: PayoutAttempt) -> PayoutAttempt { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/diesel_models/src/user/sample_data.rs | crate: diesel_models use crate::{ enums::{MandateDataType, MandateDetails}, ConnectorMandateReferenceId, PaymentAttemptNew, }; fn convert_into_normal_attempt_insert(self) -> PaymentAttemptNew { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/scheduler/src/producer.rs | crate: scheduler use common_utils::{errors::CustomResult, id_type}; use diesel_models::enums::ProcessTrackerStatus; use error_stack::{report, ResultExt}; use time::Duration; use super::{ env::logger::{self, debug, error, warn}, metrics, }; use crate::{ configs::settings::SchedulerSettings, errors, flow::SchedulerFlow, scheduler::SchedulerInterface, utils::*, SchedulerAppState, SchedulerSessionState, }; pub async fn fetch_producer_tasks( db: &dyn SchedulerInterface, conf: &SchedulerSettings, ) -> CustomResult<Vec<storage::ProcessTracker>, errors::ProcessTrackerError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/scheduler/src/producer.rs | crate: scheduler use common_utils::{errors::CustomResult, id_type}; use super::{ env::logger::{self, debug, error, warn}, metrics, }; use crate::{ configs::settings::SchedulerSettings, errors, flow::SchedulerFlow, scheduler::SchedulerInterface, utils::*, SchedulerAppState, SchedulerSessionState, }; pub async fn run_producer_flow<T>( state: &T, settings: &SchedulerSettings, ) -> CustomResult<(), errors::ProcessTrackerError> where T: SchedulerSessionState, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/scheduler/src/producer.rs | crate: scheduler use std::sync::Arc; use common_utils::{errors::CustomResult, id_type}; use diesel_models::enums::ProcessTrackerStatus; use error_stack::{report, ResultExt}; use router_env::{ instrument, tracing::{self, Instrument}, }; use time::Duration; use tokio::sync::mpsc; use super::{ env::logger::{self, debug, error, warn}, metrics, }; use crate::{ configs::settings::SchedulerSettings, errors, flow::SchedulerFlow, scheduler::SchedulerInterface, utils::*, SchedulerAppState, SchedulerSessionState, }; pub async fn start_producer<T, U, F>( state: &T, scheduler_settings: Arc<SchedulerSettings>, (tx, mut rx): (mpsc::Sender<()>, mpsc::Receiver<()>), app_state_to_session_state: F, ) -> CustomResult<(), errors::ProcessTrackerError> where F: Fn(&T, &id_type::TenantId) -> CustomResult<U, errors::ProcessTrackerError>, T: SchedulerAppState, U: SchedulerSessionState, { {use std::time::Duration;<|fim_suffix|> <|fim_middle|> Ok(())}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router_derive/src/macros/api_error.rs | crate: router_derive use std::collections::HashMap; use proc_macro2::TokenStream; use quote::quote; use syn::{ punctuated::Punctuated, token::Comma, Data, DeriveInput, Fields, Ident, ImplGenerics, TypeGenerics, Variant, WhereClause, }; use crate::macros::{ api_error::helpers::{ check_missing_attributes, get_unused_fields, ErrorTypeProperties, ErrorVariantProperties, HasErrorTypeProperties, HasErrorVariantProperties, }, helpers::non_enum_error, }; fn implement_error_message( enum_name: &Ident, variants_properties_map: &HashMap<&Variant, ErrorVariantProperties>, ) -> TokenStream { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router_derive/src/macros/api_error.rs | crate: router_derive use std::collections::HashMap; use proc_macro2::TokenStream; use quote::quote; use syn::{ punctuated::Punctuated, token::Comma, Data, DeriveInput, Fields, Ident, ImplGenerics, TypeGenerics, Variant, WhereClause, }; use crate::macros::{ api_error::helpers::{ check_missing_attributes, get_unused_fields, ErrorTypeProperties, ErrorVariantProperties, HasErrorTypeProperties, HasErrorVariantProperties, }, helpers::non_enum_error, }; fn implement_error_code( enum_name: &Ident, variants_properties_map: &HashMap<&Variant, ErrorVariantProperties>, ) -> TokenStream { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router_derive/src/macros/api_error.rs | crate: router_derive use std::collections::HashMap; use proc_macro2::TokenStream; use quote::quote; use syn::{ punctuated::Punctuated, token::Comma, Data, DeriveInput, Fields, Ident, ImplGenerics, TypeGenerics, Variant, WhereClause, }; use crate::macros::{ api_error::helpers::{ check_missing_attributes, get_unused_fields, ErrorTypeProperties, ErrorVariantProperties, HasErrorTypeProperties, HasErrorVariantProperties, }, helpers::non_enum_error, }; fn implement_error_type( enum_name: &Ident, type_properties: &ErrorTypeProperties, variants_properties_map: &HashMap<&Variant, ErrorVariantProperties>, ) -> TokenStream { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router_derive/src/macros/api_error.rs | crate: router_derive use std::collections::HashMap; use proc_macro2::TokenStream; use quote::quote; use syn::{ punctuated::Punctuated, token::Comma, Data, DeriveInput, Fields, Ident, ImplGenerics, TypeGenerics, Variant, WhereClause, }; use crate::macros::{ api_error::helpers::{ check_missing_attributes, get_unused_fields, ErrorTypeProperties, ErrorVariantProperties, HasErrorTypeProperties, HasErrorVariantProperties, }, helpers::non_enum_error, }; pub(crate) fn api_error_derive_inner(ast: &DeriveInput) -> syn::Result<TokenStream> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/router_derive/src/macros/api_error.rs | crate: router_derive use std::collections::HashMap; use proc_macro2::TokenStream; use quote::quote; use syn::{ punctuated::Punctuated, token::Comma, Data, DeriveInput, Fields, Ident, ImplGenerics, TypeGenerics, Variant, WhereClause, }; use crate::macros::{ api_error::helpers::{ check_missing_attributes, get_unused_fields, ErrorTypeProperties, ErrorVariantProperties, HasErrorTypeProperties, HasErrorVariantProperties, }, helpers::non_enum_error, }; fn implement_serialize( enum_name: &Ident, generics: (&ImplGenerics<'_>, &TypeGenerics<'_>, Option<&WhereClause>), type_properties: &ErrorTypeProperties, variants_properties_map: &HashMap<&Variant, ErrorVariantProperties>, ) -> TokenStream { { Fields::Unit => quote! {},<|fim_suffix|> <|fim_middle|> Fields::Named(ref fields) => { let fields = fields .named .iter() .map(|f| { // Safety: Named fields are guaranteed to have an identifier. #[allow(clippy::unwrap_used)] f.ident.as_ref().unwrap() }) .collect::<Punctuated<&Ident, Comma>>(); quote! { {#fields} } } } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/euclid/src/backend/interpreter/types.rs | crate: euclid use std::{collections::HashMap, fmt, ops::Deref, string::ToString}; use crate::{backend::inputs, frontend::ast::ValueType, types::EuclidKey}; fn from(input: inputs::BackendInput) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/euclid/src/backend/vir_interpreter/types.rs | crate: euclid use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ backend::inputs::BackendInput, dssa, types::{self, EuclidKey, EuclidValue, MetadataValue, NumValueRefinement, StrValue}, }; pub fn from_input(input: BackendInput) -> Self { {let payment = input.payment;<|fim_suffix|> <|fim_middle|> Self { atomic_values: enum_values, numeric_values, }}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/euclid/src/backend/vir_interpreter/types.rs | crate: euclid use crate::{ backend::inputs::BackendInput, dssa, types::{self, EuclidKey, EuclidValue, MetadataValue, NumValueRefinement, StrValue}, }; pub fn check_presence(&self, value: &EuclidValue) -> bool { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/kgraph_utils/benches/evaluation.rs | crate: kgraph_utils use criterion::{black_box, criterion_group, criterion_main, Criterion}; use euclid::{ dirval, dssa::graph::{self, CgraphExt}, frontend::dir, types::{NumValue, NumValueRefinement}, }; use hyperswitch_constraint_graph::{CycleCheck, Memoization}; fn evaluation(c: &mut Criterion) { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/kgraph_utils/benches/evaluation.rs | crate: kgraph_utils use std::{collections::HashMap, str::FromStr}; use api_models::{ admin as admin_api, enums as api_enums, payment_methods::RequestPaymentMethodTypes, }; use common_utils::types::MinorUnit; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use euclid::{ dirval, dssa::graph::{self, CgraphExt}, frontend::dir, types::{NumValue, NumValueRefinement}, }; use hyperswitch_constraint_graph::{CycleCheck, Memoization}; use kgraph_utils::{error::KgraphError, transformers::IntoDirValue, types::CountryCurrencyFilter}; fn build_test_data( total_enabled: usize, total_pm_types: usize, ) -> hyperswitch_constraint_graph::ConstraintGraph<dir::DirValue> { {use api_models::{admin::*, payment_methods::*};let mut pms_enabled: Vec<PaymentMethodsEnabled> = Vec::new();<|fim_suffix|> <|fim_middle|> #[cfg(feature = "v1")]kgraph_utils::mca::make_mca_graph(vec![stripe_account], &config) .expect("Failed graph construction")}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/build.rs | crate: external_services fn main() -> Result<(), Box<dyn std::error::Error>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/external_services/src/grpc_client/dynamic_routing.rs | crate: external_services use std::fmt::Debug; use router_env::logger; pub use contract_routing_client::ContractScoreCalculatorClient; pub use elimination_based_client::EliminationAnalyserClient; pub use success_rate_client::SuccessRateCalculatorClient; use super::Client; pub type DynamicRoutingResult<T> = CustomResult<T, DynamicRoutingError>; /// establish connection with the server pub async fn get_dynamic_routing_connection( self, client: Client, ) -> Result<RoutingStrategy, Box<dyn std::error::Error>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/outgoing_webhook_event/events.rs | crate: analytics use api_models::analytics::{outgoing_webhook_event::OutgoingWebhookLogsRequest, Granularity}; use common_utils::errors::ReportSwitchExt; use time::PrimitiveDateTime; use crate::{ query::{Aggregate, GroupByClause, QueryBuilder, ToSql, Window}, types::{AnalyticsCollection, AnalyticsDataSource, FiltersError, FiltersResult, LoadRow}, }; pub async fn get_outgoing_webhook_event<T>( merchant_id: &common_utils::id_type::MerchantId, query_param: OutgoingWebhookLogsRequest, pool: &T, ) -> FiltersResult<Vec<OutgoingWebhookLogsResult>> where T: AnalyticsDataSource + OutgoingWebhookLogsFilterAnalytics, PrimitiveDateTime: ToSql<T>, AnalyticsCollection: ToSql<T>, Granularity: GroupByClause<T>, Aggregate<&'static str>: ToSql<T>, Window<&'static str>: ToSql<T>, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/analytics/src/connector_events/events.rs | crate: analytics use api_models::analytics::{connector_events::ConnectorEventsRequest, Granularity}; use common_utils::errors::ReportSwitchExt; use time::PrimitiveDateTime; use crate::{ query::{Aggregate, GroupByClause, QueryBuilder, ToSql, Window}, types::{AnalyticsCollection, AnalyticsDataSource, FiltersError, FiltersResult, LoadRow}, }; pub async fn get_connector_events<T>( merchant_id: &common_utils::id_type::MerchantId, query_param: ConnectorEventsRequest, pool: &T, ) -> FiltersResult<Vec<ConnectorEventsResult>> where T: AnalyticsDataSource + ConnectorEventLogAnalytics, PrimitiveDateTime: ToSql<T>, AnalyticsCollection: ToSql<T>, Granularity: GroupByClause<T>, Aggregate<&'static str>: ToSql<T>, Window<&'static str>: ToSql<T>, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments