id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
hyperswitch_impl_router_-2569582000021572639_2392925778134615146 | clm | impl | // hyperswitch/crates/router/src/services/email/types.rs
impl EmailData for WelcomeToCommunity {
// Methods: get_email_data
}
| {
"chunk": null,
"crate": "router",
"enum_name": null,
"file_size": null,
"for_type": "WelcomeToCommunity",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": "EmailData"
} |
hyperswitch_method_storage_impl_MockDb_new | clm | method | // hyperswitch/crates/storage_impl/src/mock_db.rs
// impl for MockDb
pub async fn new(redis: &RedisSettings) -> error_stack::Result<Self, StorageError> {
Ok(Self {
addresses: Default::default(),
configs: Default::default(),
merchant_accounts: Default::default(),
merchant_connector_accounts: Default::default(),
payment_attempts: Default::default(),
payment_intents: Default::default(),
payment_methods: Default::default(),
customers: Default::default(),
refunds: Default::default(),
processes: Default::default(),
redis: Arc::new(
RedisStore::new(redis)
.await
.change_context(StorageError::InitializationError)?,
),
api_keys: Default::default(),
ephemeral_keys: Default::default(),
cards_info: Default::default(),
events: Default::default(),
disputes: Default::default(),
lockers: Default::default(),
mandates: Default::default(),
captures: Default::default(),
merchant_key_store: Default::default(),
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
tokenizations: Default::default(),
business_profiles: Default::default(),
reverse_lookups: Default::default(),
payment_link: Default::default(),
organizations: Default::default(),
users: Default::default(),
user_roles: Default::default(),
authorizations: Default::default(),
dashboard_metadata: Default::default(),
#[cfg(feature = "payouts")]
payout_attempt: Default::default(),
#[cfg(feature = "payouts")]
payouts: Default::default(),
authentications: Default::default(),
roles: Default::default(),
user_key_store: Default::default(),
user_authentication_methods: Default::default(),
themes: Default::default(),
hyperswitch_ai_interactions: Default::default(),
})
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "MockDb",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_MockDb_find_resource | clm | method | // hyperswitch/crates/storage_impl/src/mock_db.rs
// impl for MockDb
pub async fn find_resource<D, R>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
resources: MutexGuard<'_, Vec<D>>,
filter_fn: impl Fn(&&D) -> bool,
) -> CustomResult<Option<R>, StorageError>
where
D: Sync + ReverseConversion<R> + Clone,
R: Conversion,
{
let resource = resources.iter().find(filter_fn).cloned();
match resource {
Some(res) => Ok(Some(
res.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?,
)),
None => Ok(None),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "MockDb",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "find_resource",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_MockDb_get_resource | clm | method | // hyperswitch/crates/storage_impl/src/mock_db.rs
// impl for MockDb
pub async fn get_resource<D, R>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
resources: MutexGuard<'_, Vec<D>>,
filter_fn: impl Fn(&&D) -> bool,
error_message: String,
) -> CustomResult<R, StorageError>
where
D: Sync + ReverseConversion<R> + Clone,
R: Conversion,
{
match self
.find_resource(state, key_store, resources, filter_fn)
.await?
{
Some(res) => Ok(res),
None => Err(StorageError::ValueNotFound(error_message).into()),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "MockDb",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_resource",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_MockDb_get_resources | clm | method | // hyperswitch/crates/storage_impl/src/mock_db.rs
// impl for MockDb
pub async fn get_resources<D, R>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
resources: MutexGuard<'_, Vec<D>>,
filter_fn: impl Fn(&&D) -> bool,
error_message: String,
) -> CustomResult<Vec<R>, StorageError>
where
D: Sync + ReverseConversion<R> + Clone,
R: Conversion,
{
let resources: Vec<_> = resources.iter().filter(filter_fn).cloned().collect();
if resources.is_empty() {
Err(StorageError::ValueNotFound(error_message).into())
} else {
let pm_futures = resources
.into_iter()
.map(|pm| async {
pm.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.collect::<Vec<_>>();
let domain_resources = futures::future::try_join_all(pm_futures).await?;
Ok(domain_resources)
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "MockDb",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_resources",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_MockDb_update_resource | clm | method | // hyperswitch/crates/storage_impl/src/mock_db.rs
// impl for MockDb
pub async fn update_resource<D, R>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
mut resources: MutexGuard<'_, Vec<D>>,
resource_updated: D,
filter_fn: impl Fn(&&mut D) -> bool,
error_message: String,
) -> CustomResult<R, StorageError>
where
D: Sync + ReverseConversion<R> + Clone,
R: Conversion,
{
if let Some(pm) = resources.iter_mut().find(filter_fn) {
*pm = resource_updated.clone();
let result = resource_updated
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?;
Ok(result)
} else {
Err(StorageError::ValueNotFound(error_message).into())
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "MockDb",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "update_resource",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_MockDb_master_key | clm | method | // hyperswitch/crates/storage_impl/src/mock_db.rs
// impl for MockDb
pub fn master_key(&self) -> &[u8] {
&[
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32,
]
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "MockDb",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "master_key",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RouterStore<T>_from_config | clm | method | // hyperswitch/crates/storage_impl/src/lib.rs
// impl for RouterStore<T>
pub async fn from_config(
db_conf: T::Config,
tenant_config: &dyn TenantConfig,
encryption_key: StrongSecret<Vec<u8>>,
cache_store: Arc<RedisStore>,
inmemory_cache_stream: &str,
) -> error_stack::Result<Self, StorageError> {
let db_store = T::new(db_conf, tenant_config, false).await?;
let redis_conn = cache_store.redis_conn.clone();
let cache_store = Arc::new(RedisStore {
redis_conn: Arc::new(RedisConnectionPool::clone(
&redis_conn,
tenant_config.get_redis_key_prefix(),
)),
});
cache_store
.redis_conn
.subscribe(inmemory_cache_stream)
.await
.change_context(StorageError::InitializationError)
.attach_printable("Failed to subscribe to inmemory cache stream")?;
Ok(Self {
db_store,
cache_store,
master_encryption_key: encryption_key,
request_id: None,
})
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from_config",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RouterStore<T>_cache_store | clm | method | // hyperswitch/crates/storage_impl/src/lib.rs
// impl for RouterStore<T>
pub async fn cache_store(
cache_conf: &redis_interface::RedisSettings,
cache_error_signal: tokio::sync::oneshot::Sender<()>,
) -> error_stack::Result<Arc<RedisStore>, StorageError> {
let cache_store = RedisStore::new(cache_conf)
.await
.change_context(StorageError::InitializationError)
.attach_printable("Failed to create cache store")?;
cache_store.set_error_callback(cache_error_signal);
Ok(Arc::new(cache_store))
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "cache_store",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RouterStore<T>_master_key | clm | method | // hyperswitch/crates/storage_impl/src/lib.rs
// impl for RouterStore<T>
pub fn master_key(&self) -> &StrongSecret<Vec<u8>> {
&self.master_encryption_key
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "master_key",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RouterStore<T>_call_database | clm | method | // hyperswitch/crates/storage_impl/src/lib.rs
// impl for RouterStore<T>
pub async fn call_database<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query: R,
) -> error_stack::Result<D, StorageError>
where
D: Debug + Sync + Conversion,
R: futures::Future<Output = error_stack::Result<M, diesel_models::errors::DatabaseError>>
+ Send,
M: ReverseConversion<D>,
{
execute_query
.await
.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "call_database",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RouterStore<T>_find_optional_resource | clm | method | // hyperswitch/crates/storage_impl/src/lib.rs
// impl for RouterStore<T>
pub async fn find_optional_resource<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query_fut: R,
) -> error_stack::Result<Option<D>, StorageError>
where
D: Debug + Sync + Conversion,
R: futures::Future<
Output = error_stack::Result<Option<M>, diesel_models::errors::DatabaseError>,
> + Send,
M: ReverseConversion<D>,
{
match execute_query_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})? {
Some(resource) => Ok(Some(
resource
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?,
)),
None => Ok(None),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "find_optional_resource",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RouterStore<T>_find_resources | clm | method | // hyperswitch/crates/storage_impl/src/lib.rs
// impl for RouterStore<T>
pub async fn find_resources<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query: R,
) -> error_stack::Result<Vec<D>, StorageError>
where
D: Debug + Sync + Conversion,
R: futures::Future<
Output = error_stack::Result<Vec<M>, diesel_models::errors::DatabaseError>,
> + Send,
M: ReverseConversion<D>,
{
let resource_futures = execute_query
.await
.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})?
.into_iter()
.map(|resource| async {
resource
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.collect::<Vec<_>>();
let resources = futures::future::try_join_all(resource_futures).await?;
Ok(resources)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "find_resources",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RouterStore<T>_test_store | clm | method | // hyperswitch/crates/storage_impl/src/lib.rs
// impl for RouterStore<T>
pub async fn test_store(
db_conf: T::Config,
tenant_config: &dyn TenantConfig,
cache_conf: &redis_interface::RedisSettings,
encryption_key: StrongSecret<Vec<u8>>,
) -> error_stack::Result<Self, StorageError> {
// TODO: create an error enum and return proper error here
let db_store = T::new(db_conf, tenant_config, true).await?;
let cache_store = RedisStore::new(cache_conf)
.await
.change_context(StorageError::InitializationError)
.attach_printable("failed to create redis cache")?;
Ok(Self {
db_store,
cache_store: Arc::new(cache_store),
master_encryption_key: encryption_key,
request_id: None,
})
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "test_store",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_StorageError_is_db_not_found | clm | method | // hyperswitch/crates/storage_impl/src/errors.rs
// impl for StorageError
pub fn is_db_not_found(&self) -> bool {
match self {
Self::DatabaseError(err) => matches!(err.current_context(), DatabaseError::NotFound),
Self::ValueNotFound(_) => true,
Self::RedisError(err) => matches!(err.current_context(), RedisError::NotFound),
_ => false,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "StorageError",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "is_db_not_found",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_StorageError_is_db_unique_violation | clm | method | // hyperswitch/crates/storage_impl/src/errors.rs
// impl for StorageError
pub fn is_db_unique_violation(&self) -> bool {
match self {
Self::DatabaseError(err) => {
matches!(err.current_context(), DatabaseError::UniqueViolation,)
}
Self::DuplicateValue { .. } => true,
_ => false,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "StorageError",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "is_db_unique_violation",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_from_store | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub fn from_store(
store: RouterStore<T>,
drainer_stream_name: String,
drainer_num_partitions: u8,
ttl_for_kv: u32,
soft_kill: Option<bool>,
) -> Self {
let request_id = store.request_id.clone();
Self {
router_store: store,
drainer_stream_name,
drainer_num_partitions,
ttl_for_kv,
request_id,
soft_kill_mode: soft_kill.unwrap_or(false),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from_store",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_master_key | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub fn master_key(&self) -> &StrongSecret<Vec<u8>> {
self.router_store.master_key()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "master_key",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_get_drainer_stream_name | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub fn get_drainer_stream_name(&self, shard_key: &str) -> String {
format!("{{{}}}_{}", shard_key, self.drainer_stream_name)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_drainer_stream_name",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_push_to_drainer_stream | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub async fn push_to_drainer_stream<R>(
&self,
redis_entry: kv::TypedSql,
partition_key: PartitionKey<'_>,
) -> error_stack::Result<(), RedisError>
where
R: KvStorePartition,
{
let global_id = format!("{partition_key}");
let request_id = self.request_id.clone().unwrap_or_default();
let shard_key = R::shard_key(partition_key, self.drainer_num_partitions);
let stream_name = self.get_drainer_stream_name(&shard_key);
self.router_store
.cache_store
.redis_conn
.stream_append_entry(
&stream_name.into(),
&redis_interface::RedisEntryId::AutoGeneratedID,
redis_entry
.to_field_value_pairs(request_id, global_id)
.change_context(RedisError::JsonSerializationFailed)?,
)
.await
.map(|_| metrics::KV_PUSHED_TO_DRAINER.add(1, &[]))
.inspect_err(|error| {
metrics::KV_FAILED_TO_PUSH_TO_DRAINER.add(1, &[]);
logger::error!(?error, "Failed to add entry in drainer stream");
})
.change_context(RedisError::StreamAppendFailed)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "push_to_drainer_stream",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_find_resource_by_id | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub async fn find_resource_by_id<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
find_resource_db_fut: R,
find_by: FindResourceBy<'_>,
) -> error_stack::Result<D, errors::StorageError>
where
D: DomainType,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<M, DatabaseError>> + Send,
{
let database_call = || async {
find_resource_db_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
};
let storage_scheme = Box::pin(decide_storage_scheme::<T, M>(
self,
storage_scheme,
Op::Find,
))
.await;
let res = || async {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => database_call().await,
MerchantStorageScheme::RedisKv => {
let (field, key) = match find_by {
FindResourceBy::Id(field, key) => (field, key),
FindResourceBy::LookupId(lookup_id) => {
let lookup = fallback_reverse_lookup_not_found!(
self.get_lookup_by_lookup_id(&lookup_id, storage_scheme)
.await,
database_call().await
);
(
lookup.clone().sk_id,
PartitionKey::CombinationKey {
combination: &lookup.clone().pk_id,
},
)
}
};
Box::pin(try_redis_get_else_try_database_get(
async {
Box::pin(kv_wrapper(self, KvOperation::<M>::HGet(&field), key))
.await?
.try_into_hget()
},
database_call,
))
.await
}
}
};
res()
.await?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "find_resource_by_id",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_find_optional_resource_by_id | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub async fn find_optional_resource_by_id<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
find_resource_db_fut: R,
find_by: FindResourceBy<'_>,
) -> error_stack::Result<Option<D>, errors::StorageError>
where
D: DomainType,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<Option<M>, DatabaseError>> + Send,
{
let database_call = || async {
find_resource_db_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
};
let storage_scheme = Box::pin(decide_storage_scheme::<T, M>(
self,
storage_scheme,
Op::Find,
))
.await;
let res = || async {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => database_call().await,
MerchantStorageScheme::RedisKv => {
let (field, key) = match find_by {
FindResourceBy::Id(field, key) => (field, key),
FindResourceBy::LookupId(lookup_id) => {
let lookup = fallback_reverse_lookup_not_found!(
self.get_lookup_by_lookup_id(&lookup_id, storage_scheme)
.await,
database_call().await
);
(
lookup.clone().sk_id,
PartitionKey::CombinationKey {
combination: &lookup.clone().pk_id,
},
)
}
};
Box::pin(try_redis_get_else_try_database_get(
async {
Box::pin(kv_wrapper(self, KvOperation::<M>::HGet(&field), key))
.await?
.try_into_hget()
.map(Some)
},
database_call,
))
.await
}
}
};
match res().await? {
Some(resource) => Ok(Some(
resource
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)?,
)),
None => Ok(None),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "find_optional_resource_by_id",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_insert_resource | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub async fn insert_resource<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
create_resource_fut: R,
resource_new: M,
InsertResourceParams {
insertable,
reverse_lookups,
key,
identifier,
resource_type,
}: InsertResourceParams<'_>,
) -> error_stack::Result<D, errors::StorageError>
where
D: Debug + Sync + Conversion,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<M, DatabaseError>> + Send,
{
let storage_scheme = Box::pin(decide_storage_scheme::<_, M>(
self,
storage_scheme,
Op::Insert,
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => create_resource_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
}),
MerchantStorageScheme::RedisKv => {
let key_str = key.to_string();
let reverse_lookup_entry = |v: String| diesel_models::ReverseLookupNew {
sk_id: identifier.clone(),
pk_id: key_str.clone(),
lookup_id: v,
source: resource_type.to_string(),
updated_by: storage_scheme.to_string(),
};
let results = reverse_lookups
.into_iter()
.map(|v| self.insert_reverse_lookup(reverse_lookup_entry(v), storage_scheme));
futures::future::try_join_all(results).await?;
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Insert {
insertable: Box::new(insertable),
},
};
match Box::pin(kv_wrapper::<M, _, _>(
self,
KvOperation::<M>::HSetNx(&identifier, &resource_new, redis_entry),
key.clone(),
))
.await
.map_err(|err| err.to_redis_failed_response(&key.to_string()))?
.try_into_hsetnx()
{
Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue {
entity: resource_type,
key: Some(key_str),
}
.into()),
Ok(HsetnxReply::KeySet) => Ok(resource_new),
Err(er) => Err(er).change_context(errors::StorageError::KVError),
}
}
}?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "insert_resource",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_update_resource | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub async fn update_resource<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
update_resource_fut: R,
updated_resource: M,
UpdateResourceParams {
updateable,
operation,
}: UpdateResourceParams<'_>,
) -> error_stack::Result<D, errors::StorageError>
where
D: Debug + Sync + Conversion,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<M, DatabaseError>> + Send,
{
match operation {
Op::Update(key, field, updated_by) => {
let storage_scheme = Box::pin(decide_storage_scheme::<_, M>(
self,
storage_scheme,
Op::Update(key.clone(), field, updated_by),
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
update_resource_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
}
MerchantStorageScheme::RedisKv => {
let key_str = key.to_string();
let redis_value = serde_json::to_string(&updated_resource)
.change_context(errors::StorageError::SerializationFailed)?;
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Update {
updatable: Box::new(updateable),
},
};
Box::pin(kv_wrapper::<(), _, _>(
self,
KvOperation::<M>::Hset((field, redis_value), redis_entry),
key,
))
.await
.map_err(|err| err.to_redis_failed_response(&key_str))?
.try_into_hset()
.change_context(errors::StorageError::KVError)?;
Ok(updated_resource)
}
}
}
_ => Err(errors::StorageError::KVError.into()),
}?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "update_resource",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_KVRouterStore<T>_filter_resources | clm | method | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
// impl for KVRouterStore<T>
pub async fn filter_resources<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
filter_resource_db_fut: R,
filter_fn: impl Fn(&M) -> bool,
FilterResourceParams {
key,
pattern,
limit,
}: FilterResourceParams<'_>,
) -> error_stack::Result<Vec<D>, errors::StorageError>
where
D: Debug + Sync + Conversion,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<Vec<M>, DatabaseError>> + Send,
{
let db_call = || async {
filter_resource_db_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
};
let resources = match storage_scheme {
MerchantStorageScheme::PostgresOnly => db_call().await,
MerchantStorageScheme::RedisKv => {
let redis_fut = async {
let kv_result = Box::pin(kv_wrapper::<M, _, _>(
self,
KvOperation::<M>::Scan(pattern),
key,
))
.await?
.try_into_scan();
kv_result.map(|records| records.into_iter().filter(filter_fn).collect())
};
Box::pin(find_all_combined_kv_database(redis_fut, db_call, limit)).await
}
}?;
let resource_futures = resources
.into_iter()
.map(|pm| async {
pm.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
})
.collect::<Vec<_>>();
futures::future::try_join_all(resource_futures).await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "KVRouterStore<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "filter_resources",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RedisStore_new | clm | method | // hyperswitch/crates/storage_impl/src/redis.rs
// impl for RedisStore
pub async fn new(
conf: &redis_interface::RedisSettings,
) -> error_stack::Result<Self, redis_interface::errors::RedisError> {
Ok(Self {
redis_conn: Arc::new(redis_interface::RedisConnectionPool::new(conf).await?),
})
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RedisStore",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_RedisStore_set_error_callback | clm | method | // hyperswitch/crates/storage_impl/src/redis.rs
// impl for RedisStore
pub fn set_error_callback(&self, callback: tokio::sync::oneshot::Sender<()>) {
let redis_clone = self.redis_conn.clone();
let _task_handle = tokio::spawn(
async move {
redis_clone.on_error(callback).await;
}
.in_current_span(),
);
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "RedisStore",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "set_error_callback",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Store_new | clm | method | // hyperswitch/crates/drainer/src/services.rs
// impl for Store
pub async fn new(config: &crate::Settings, test_transaction: bool, tenant: &Tenant) -> Self {
let redis_conn = crate::connection::redis_connection(config).await;
Self {
master_pool: diesel_make_pg_pool(
config.master_database.get_inner(),
test_transaction,
&tenant.schema,
)
.await,
redis_conn: Arc::new(RedisConnectionPool::clone(
&redis_conn,
&tenant.redis_key_prefix,
)),
config: StoreConfig {
drainer_stream_name: config.drainer.stream_name.clone(),
drainer_num_partitions: config.drainer.num_partitions,
use_legacy_version: config.redis.use_legacy_version,
},
request_id: None,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Store",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_CacheKind<'_>_get_key_without_prefix | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for CacheKind<'_>
pub(crate) fn get_key_without_prefix(&self) -> &str {
match self {
CacheKind::Config(key)
| CacheKind::Accounts(key)
| CacheKind::Routing(key)
| CacheKind::DecisionManager(key)
| CacheKind::Surcharge(key)
| CacheKind::CGraph(key)
| CacheKind::SuccessBasedDynamicRoutingCache(key)
| CacheKind::EliminationBasedDynamicRoutingCache(key)
| CacheKind::ContractBasedDynamicRoutingCache(key)
| CacheKind::PmFiltersCGraph(key)
| CacheKind::All(key) => key,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "CacheKind<'_>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_key_without_prefix",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_w(
| clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
b fn new(
name: &'static str,
time_to_live: u64,
time_to_idle: u64,
max_capacity: Option<u64>,
) -> Self {
// Record the metrics of manual invalidation of cache entry by the application
let eviction_listener = move |_, _, cause| {
metrics::IN_MEMORY_CACHE_EVICTION_COUNT.add(
1,
router_env::metric_attributes!(
("cache_type", name.to_owned()),
("removal_cause", format!("{:?}", cause)),
),
);
};
let mut cache_builder = MokaCache::builder()
.time_to_live(std::time::Duration::from_secs(time_to_live))
.time_to_idle(std::time::Duration::from_secs(time_to_idle))
.eviction_listener(eviction_listener);
if let Some(capacity) = max_capacity {
cache_builder = cache_builder.max_capacity(capacity * 1024 * 1024);
}
Self {
name,
inner: cache_builder.build(),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "w(\n",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_sh<T | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
b async fn push<T: Cacheable>(&self, key: CacheKey, val: T) {
self.inner.insert(key.into(), Arc::new(val)).await;
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "sh<T",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_t_val<T | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
b async fn get_val<T: Clone + Cacheable>(&self, key: CacheKey) -> Option<T> {
let val = self.inner.get::<String>(&key.into()).await;
// Add cache hit and cache miss metrics
if val.is_some() {
metrics::IN_MEMORY_CACHE_HIT
.add(1, router_env::metric_attributes!(("cache_type", self.name)));
} else {
metrics::IN_MEMORY_CACHE_MISS
.add(1, router_env::metric_attributes!(("cache_type", self.name)));
}
let val = (*val?).as_any().downcast_ref::<T>().cloned();
val
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "t_val<T",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_ists(& | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
b async fn exists(&self, key: CacheKey) -> bool {
self.inner.contains_key::<String>(&key.into())
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "ists(&",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_move(& | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
b async fn remove(&self, key: CacheKey) {
self.inner.invalidate::<String>(&key.into()).await;
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "move(&",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_n_pending_tasks(& | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
ync fn run_pending_tasks(&self) {
self.inner.run_pending_tasks().await;
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "n_pending_tasks(&",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_t_entry_count(& | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
get_entry_count(&self) -> u64 {
self.inner.entry_count()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "t_entry_count(&",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_me(& | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
b fn name(&self) -> &'static str {
self.name
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "me(&",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_storage_impl_Cache_cord_entry_count_metric(& | clm | method | // hyperswitch/crates/storage_impl/src/redis/cache.rs
// impl for Cache
b async fn record_entry_count_metric(&self) {
self.run_pending_tasks().await;
metrics::IN_MEMORY_CACHE_ENTRY_COUNT.record(
self.get_entry_count(),
router_env::metric_attributes!(("cache_type", self.name)),
);
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": "Cache",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "cord_entry_count_metric(&",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestContent_get_inner_value | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestContent
pub fn get_inner_value(&self) -> Secret<String> {
match self {
Self::Json(i) => serde_json::to_string(&i).unwrap_or_default().into(),
Self::FormUrlEncoded(i) => serde_urlencoded::to_string(i).unwrap_or_default().into(),
Self::Xml(i) => quick_xml::se::to_string(&i).unwrap_or_default().into(),
Self::FormData((_, i)) => serde_json::to_string(i).unwrap_or_default().into(),
Self::RawBytes(_) => String::new().into(),
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestContent",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_inner_value",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Request_add_default_headers | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for Request
pub fn add_default_headers(&mut self) {
self.headers.extend(default_request_headers());
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Request",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "add_default_headers",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Request_add_header | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for Request
pub fn add_header(&mut self, header: &str, value: Maskable<String>) {
self.headers.insert((String::from(header), value));
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Request",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "add_header",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_new | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn new() -> Self {
Self {
method: Method::Get,
url: String::with_capacity(1024),
headers: std::collections::HashSet::new(),
certificate: None,
certificate_key: None,
body: None,
ca_certificate: None,
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_set_body | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn set_body<T: Into<RequestContent>>(mut self, body: T) -> Self {
self.body.replace(body.into());
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "set_body",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_add_certificate | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn add_certificate(mut self, certificate: Option<Secret<String>>) -> Self {
self.certificate = certificate;
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "add_certificate",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_add_certificate_key | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn add_certificate_key(mut self, certificate_key: Option<Secret<String>>) -> Self {
self.certificate_key = certificate_key;
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "add_certificate_key",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_url | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn url(mut self, url: &str) -> Self {
self.url = url.into();
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "url",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_method | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn method(mut self, method: Method) -> Self {
self.method = method;
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "method",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_attach_default_headers | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn attach_default_headers(mut self) -> Self {
self.headers.extend(default_request_headers());
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "attach_default_headers",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_header | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn header(mut self, header: &str, value: &str) -> Self {
self.headers.insert((header.into(), value.into()));
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "header",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_headers | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn headers(mut self, headers: Vec<(String, Maskable<String>)>) -> Self {
self.headers.extend(headers);
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "headers",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_set_optional_body | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn set_optional_body<T: Into<RequestContent>>(mut self, body: Option<T>) -> Self {
body.map(|body| self.body.replace(body.into()));
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "set_optional_body",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_add_ca_certificate_pem | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn add_ca_certificate_pem(mut self, ca_certificate: Option<Secret<String>>) -> Self {
self.ca_certificate = ca_certificate;
self
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "add_ca_certificate_pem",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_build | clm | method | // hyperswitch/crates/common_utils/src/request.rs
// impl for RequestBuilder
pub fn build(self) -> Request {
Request {
method: self.method,
url: self.url,
headers: self.headers,
certificate: self.certificate,
certificate_key: self.certificate_key,
body: self.body,
ca_certificate: self.ca_certificate,
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "build",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestBuilder_header | clm | method | // hyperswitch/crates/router/src/services/api/client.rs
// impl for RequestBuilder
fn header(&mut self, key: String, value: Maskable<String>) -> CustomResult<(), ApiClientError> {
let header_value = match value {
Maskable::Masked(hvalue) => HeaderValue::from_str(hvalue.peek()).map(|mut h| {
h.set_sensitive(true);
h
}),
Maskable::Normal(hvalue) => HeaderValue::from_str(&hvalue),
}
.change_context(ApiClientError::HeaderMapConstructionFailed)?;
self.inner = self.inner.take().map(|r| r.header(key, header_value));
Ok(())
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestBuilder",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "header",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_SemanticVersion_get_major | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for SemanticVersion
pub fn get_major(&self) -> u64 {
self.0.major
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "SemanticVersion",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_major",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_SemanticVersion_get_minor | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for SemanticVersion
pub fn get_minor(&self) -> u64 {
self.0.minor
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "SemanticVersion",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_minor",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_StringMajorUnit_new | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for StringMajorUnit
fn new(value: String) -> Self {
Self(value)
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "StringMajorUnit",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_StringMajorUnit_zero | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for StringMajorUnit
pub fn zero() -> Self {
Self("0".to_string())
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "StringMajorUnit",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "zero",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_StringMajorUnit_to_minor_unit_as_i64 | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for StringMajorUnit
fn to_minor_unit_as_i64(
&self,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_decimal = Decimal::from_str(&self.0).map_err(|e| {
ParsingError::StringToDecimalConversionFailure {
error: e.to_string(),
}
})?;
let amount = if currency.is_zero_decimal_currency() {
amount_decimal
} else if currency.is_three_decimal_currency() {
amount_decimal * Decimal::from(1000)
} else {
amount_decimal * Decimal::from(100)
};
let amount_i64 = amount
.to_i64()
.ok_or(ParsingError::DecimalToI64ConversionFailure)?;
Ok(MinorUnit::new(amount_i64))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "StringMajorUnit",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "to_minor_unit_as_i64",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_StringMajorUnit_get_amount_as_string | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for StringMajorUnit
pub fn get_amount_as_string(&self) -> String {
self.0.clone()
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "StringMajorUnit",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_amount_as_string",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Url_wrap | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for Url
pub fn wrap(url: url::Url) -> Self {
Self(url)
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Url",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "wrap",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Url_into_inner | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for Url
pub fn into_inner(self) -> url::Url {
self.0
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Url",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "into_inner",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Url_add_query_params | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for Url
pub fn add_query_params(mut self, (key, value): (&str, &str)) -> Self {
let url = self
.0
.query_pairs_mut()
.append_pair(key, value)
.finish()
.clone();
Self(url)
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Url",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "add_query_params",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_LengthString<MAX_LENGTH, MIN_LENGTH>_new_unchecked | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for LengthString<MAX_LENGTH, MIN_LENGTH>
pub(crate) fn new_unchecked(input_string: String) -> Self {
Self(input_string)
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "LengthString<MAX_LENGTH, MIN_LENGTH>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new_unchecked",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Description_from_str_unchecked | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for Description
pub fn from_str_unchecked(input_str: &'static str) -> Self {
Self(LengthString::new_unchecked(input_str.to_owned()))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Description",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from_str_unchecked",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_PublishableKey_get_string_repr | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for PublishableKey
pub fn get_string_repr(&self) -> &str {
&self.0 .0
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "PublishableKey",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_string_repr",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_PublishableKey_generate | clm | method | // hyperswitch/crates/common_utils/src/types.rs
// impl for PublishableKey
pub fn generate(env_prefix: &'static str) -> Self {
let publishable_key_string = format!("pk_{env_prefix}_{}", uuid::Uuid::now_v7().simple());
Self(LengthString::new_unchecked(publishable_key_string))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "PublishableKey",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "generate",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryption_new | clm | method | // hyperswitch/crates/common_utils/src/encryption.rs
// impl for Encryption
pub fn new(item: Secret<Vec<u8>, EncryptionStrategy>) -> Self {
Self { inner: item }
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryption",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryption_into_inner | clm | method | // hyperswitch/crates/common_utils/src/encryption.rs
// impl for Encryption
pub fn into_inner(self) -> Secret<Vec<u8>, EncryptionStrategy> {
self.inner
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryption",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "into_inner",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryption_get_inner | clm | method | // hyperswitch/crates/common_utils/src/encryption.rs
// impl for Encryption
pub fn get_inner(&self) -> &Secret<Vec<u8>, EncryptionStrategy> {
&self.inner
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryption",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_inner",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_UcsReferenceId_get_string_repr | clm | method | // hyperswitch/crates/common_utils/src/ucs_types.rs
// impl for UcsReferenceId
pub fn get_string_repr(&self) -> &str {
match self {
Self::Payment(id) => id.get_string_repr(),
Self::Refund(id) => id.get_string_repr(),
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "UcsReferenceId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_string_repr",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_LengthId<MAX_LENGTH, MIN_LENGTH>_from | clm | method | // hyperswitch/crates/common_utils/src/id_type.rs
// impl for LengthId<MAX_LENGTH, MIN_LENGTH>
pub fn from(input_string: Cow<'static, str>) -> Result<Self, LengthIdError> {
let trimmed_input_string = input_string.trim().to_string();
let length_of_input_string = u8::try_from(trimmed_input_string.len())
.map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?;
when(length_of_input_string > MAX_LENGTH, || {
Err(LengthIdError::MaxLengthViolated(MAX_LENGTH))
})?;
when(length_of_input_string < MIN_LENGTH, || {
Err(LengthIdError::MinLengthViolated(MIN_LENGTH))
})?;
let alphanumeric_id = match AlphaNumericId::from(trimmed_input_string.into()) {
Ok(valid_alphanumeric_id) => valid_alphanumeric_id,
Err(error) => Err(LengthIdError::AlphanumericIdError(error))?,
};
Ok(Self(alphanumeric_id))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "LengthId<MAX_LENGTH, MIN_LENGTH>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_LengthId<MAX_LENGTH, MIN_LENGTH>_new_unchecked | clm | method | // hyperswitch/crates/common_utils/src/id_type.rs
// impl for LengthId<MAX_LENGTH, MIN_LENGTH>
pub(crate) fn new_unchecked(alphanumeric_id: AlphaNumericId) -> Self {
Self(alphanumeric_id)
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "LengthId<MAX_LENGTH, MIN_LENGTH>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new_unchecked",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_LengthId<MAX_LENGTH, MIN_LENGTH>_new | clm | method | // hyperswitch/crates/common_utils/src/id_type.rs
// impl for LengthId<MAX_LENGTH, MIN_LENGTH>
pub fn new(prefix: &str) -> Self {
Self(AlphaNumericId::new(prefix))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "LengthId<MAX_LENGTH, MIN_LENGTH>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_LengthId<MAX_LENGTH, MIN_LENGTH>_from_alphanumeric_id | clm | method | // hyperswitch/crates/common_utils/src/id_type.rs
// impl for LengthId<MAX_LENGTH, MIN_LENGTH>
pub(crate) fn from_alphanumeric_id(
alphanumeric_id: AlphaNumericId,
) -> Result<Self, LengthIdError> {
let length_of_input_string = alphanumeric_id.0.len();
let length_of_input_string = u8::try_from(length_of_input_string)
.map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?;
when(length_of_input_string > MAX_LENGTH, || {
Err(LengthIdError::MaxLengthViolated(MAX_LENGTH))
})?;
when(length_of_input_string < MIN_LENGTH, || {
Err(LengthIdError::MinLengthViolated(MIN_LENGTH))
})?;
Ok(Self(alphanumeric_id))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "LengthId<MAX_LENGTH, MIN_LENGTH>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from_alphanumeric_id",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_NonceSequence_current | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for NonceSequence
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
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "NonceSequence",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "current",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_NonceSequence_from_bytes | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for NonceSequence
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);
Self(sequence_number)
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "NonceSequence",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from_bytes",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Ed25519_validate_inputs | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for Ed25519
fn validate_inputs(
public_key: &[u8],
signature: &[u8],
) -> CustomResult<(), errors::CryptoError> {
// Validate public key length
if public_key.len() != Self::ED25519_PUBLIC_KEY_LEN {
return Err(errors::CryptoError::InvalidKeyLength).attach_printable(format!(
"Invalid ED25519 public key length: expected {} bytes, got {}",
Self::ED25519_PUBLIC_KEY_LEN,
public_key.len()
));
}
// Validate signature length
if signature.len() != Self::ED25519_SIGNATURE_LEN {
return Err(errors::CryptoError::InvalidKeyLength).attach_printable(format!(
"Invalid ED25519 signature length: expected {} bytes, got {}",
Self::ED25519_SIGNATURE_LEN,
signature.len()
));
}
Ok(())
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Ed25519",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "validate_inputs",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryptable<Secret<T, S>>_new | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for Encryptable<Secret<T, S>>
pub fn new(
masked_data: Secret<T, S>,
encrypted_data: Secret<Vec<u8>, EncryptionStrategy>,
) -> Self {
Self {
inner: masked_data,
encrypted: encrypted_data,
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryptable<Secret<T, S>>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "new",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryptable<T>_into_inner | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for Encryptable<T>
pub fn into_inner(self) -> T {
self.inner
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryptable<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "into_inner",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryptable<T>_get_inner | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for Encryptable<T>
pub fn get_inner(&self) -> &T {
&self.inner
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryptable<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_inner",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryptable<T>_into_encrypted | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for Encryptable<T>
pub fn into_encrypted(self) -> Secret<Vec<u8>, EncryptionStrategy> {
self.encrypted
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryptable<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "into_encrypted",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryptable<T>_deserialize_inner_value | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for Encryptable<T>
pub fn deserialize_inner_value<U, F>(
self,
f: F,
) -> CustomResult<Encryptable<U>, errors::ParsingError>
where
F: FnOnce(T) -> CustomResult<U, errors::ParsingError>,
U: Clone,
{
let inner = self.inner;
let encrypted = self.encrypted;
let inner = f(inner)?;
Ok(Encryptable { inner, encrypted })
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryptable<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "deserialize_inner_value",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_Encryptable<T>_map | clm | method | // hyperswitch/crates/common_utils/src/crypto.rs
// impl for Encryptable<T>
pub fn map<U: Clone>(self, f: impl FnOnce(T) -> U) -> Encryptable<U> {
let encrypted_data = self.encrypted;
let masked_data = f(self.inner);
Encryptable {
inner: masked_data,
encrypted: encrypted_data,
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "Encryptable<T>",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "map",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_RequestExtendedAuthorizationBool_is_true | clm | method | // hyperswitch/crates/common_utils/src/types/primitive_wrappers.rs
// impl for RequestExtendedAuthorizationBool
pub fn is_true(&self) -> bool {
self.0
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "RequestExtendedAuthorizationBool",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "is_true",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_KeyManagerState_add_confirm_value_in_infra_values | clm | method | // hyperswitch/crates/common_utils/src/types/keymanager.rs
// impl for KeyManagerState
pub fn add_confirm_value_in_infra_values(
&self,
is_confirm_operation: bool,
) -> Option<serde_json::Value> {
self.infra_values.clone().map(|mut infra_values| {
if is_confirm_operation {
infra_values.as_object_mut().map(|obj| {
obj.insert(
"is_confirm_operation".to_string(),
serde_json::Value::Bool(true),
)
});
}
infra_values
})
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "KeyManagerState",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "add_confirm_value_in_infra_values",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_DecryptedData_from_data | clm | method | // hyperswitch/crates/common_utils/src/types/keymanager.rs
// impl for DecryptedData
pub fn from_data(data: StrongSecret<Vec<u8>>) -> Self {
Self(data)
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "DecryptedData",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from_data",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_DecryptedData_inner | clm | method | // hyperswitch/crates/common_utils/src/types/keymanager.rs
// impl for DecryptedData
pub fn inner(self) -> StrongSecret<Vec<u8>> {
self.0
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "DecryptedData",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "inner",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_ResourceId_to_str | clm | method | // hyperswitch/crates/common_utils/src/types/authentication.rs
// impl for ResourceId
pub fn to_str(&self) -> &str {
match self {
Self::Payment(id) => id.get_string_repr(),
Self::Customer(id) => id.get_string_repr(),
Self::PaymentMethodSession(id) => id.get_string_repr(),
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "ResourceId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "to_str",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_OrganizationId_try_from_string | clm | method | // hyperswitch/crates/common_utils/src/id_type/organization.rs
// impl for OrganizationId
pub fn try_from_string(org_id: String) -> CustomResult<Self, ValidationError> {
Self::try_from(std::borrow::Cow::from(org_id))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "OrganizationId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "try_from_string",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_TenantId_get_default_global_tenant_id | clm | method | // hyperswitch/crates/common_utils/src/id_type/tenant.rs
// impl for TenantId
pub fn get_default_global_tenant_id() -> Self {
Self(super::LengthId::new_unchecked(
super::AlphaNumericId::new_unchecked(DEFAULT_GLOBAL_TENANT_ID.to_string()),
))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "TenantId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_default_global_tenant_id",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_TenantId_try_from_string | clm | method | // hyperswitch/crates/common_utils/src/id_type/tenant.rs
// impl for TenantId
pub fn try_from_string(tenant_id: String) -> CustomResult<Self, ValidationError> {
Self::try_from(std::borrow::Cow::from(tenant_id))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "TenantId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "try_from_string",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_MerchantConnectorAccountId_wrap | clm | method | // hyperswitch/crates/common_utils/src/id_type/merchant_connector_account.rs
// impl for MerchantConnectorAccountId
pub fn wrap(merchant_connector_account_id: String) -> CustomResult<Self, ValidationError> {
Self::try_from(std::borrow::Cow::from(merchant_connector_account_id))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "MerchantConnectorAccountId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "wrap",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_GlobalEntity_prefix | clm | method | // hyperswitch/crates/common_utils/src/id_type/global_id.rs
// impl for GlobalEntity
fn prefix(self) -> &'static str {
match self {
Self::Customer => "cus",
Self::Payment => "pay",
Self::PaymentMethod => "pm",
Self::Attempt => "att",
Self::Refund => "ref",
Self::PaymentMethodSession => "pms",
Self::Token => "tok",
}
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "GlobalEntity",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "prefix",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_CellId_from_str | clm | method | // hyperswitch/crates/common_utils/src/id_type/global_id.rs
// impl for CellId
fn from_str(cell_id_string: impl AsRef<str>) -> Result<Self, CellIdError> {
let trimmed_input_string = cell_id_string.as_ref().trim().to_string();
let alphanumeric_id = AlphaNumericId::from(trimmed_input_string.into())?;
let length_id = LengthId::from_alphanumeric_id(alphanumeric_id)?;
Ok(Self(length_id))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "CellId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "from_str",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_AuthenticationId_generate_authentication_id | clm | method | // hyperswitch/crates/common_utils/src/id_type/authentication.rs
// impl for AuthenticationId
pub fn generate_authentication_id(prefix: &'static str) -> Self {
Self(crate::generate_ref_id_with_default_length(prefix))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "AuthenticationId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "generate_authentication_id",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_AuthenticationId_get_external_authentication_request_poll_id | clm | method | // hyperswitch/crates/common_utils/src/id_type/authentication.rs
// impl for AuthenticationId
pub fn get_external_authentication_request_poll_id(&self) -> String {
format!("external_authentication_{}", self.get_string_repr())
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "AuthenticationId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_external_authentication_request_poll_id",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_ApiKeyId_generate_key_id | clm | method | // hyperswitch/crates/common_utils/src/id_type/api_key.rs
// impl for ApiKeyId
pub fn generate_key_id(prefix: &'static str) -> Self {
Self(crate::generate_ref_id_with_default_length(prefix))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "ApiKeyId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "generate_key_id",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_WebhookEndpointId_try_from_string | clm | method | // hyperswitch/crates/common_utils/src/id_type/webhook_endpoint.rs
// impl for WebhookEndpointId
pub fn try_from_string(webhook_endpoint_id: String) -> CustomResult<Self, ValidationError> {
Self::try_from(std::borrow::Cow::from(webhook_endpoint_id))
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "WebhookEndpointId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "try_from_string",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_method_common_utils_GlobalPaymentMethodSessionId_get_redis_key | clm | method | // hyperswitch/crates/common_utils/src/id_type/global_id/payment_methods.rs
// impl for GlobalPaymentMethodSessionId
pub fn get_redis_key(&self) -> String {
format!("payment_method_session:{}", self.get_string_repr())
}
| {
"chunk": null,
"crate": "common_utils",
"enum_name": null,
"file_size": null,
"for_type": "GlobalPaymentMethodSessionId",
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": null,
"method_name": "get_redis_key",
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.