text
stringlengths
70
351k
source
stringclasses
4 values
// file: hyperswitch/crates/common_utils/tests/percentage.rs | crate: common_utils use common_utils::{errors::PercentageError, types::Percentage}; fn invalid_precision() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { let percentage = Percentage::<PRECISION_2>::from_string("2.221".to_string()); assert!(percentage.is_err()); if let Err(err) = percentage { assert_eq!( *err.current_context(), PercentageError::InvalidPercentageValue ) } Ok(()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/tests/percentage.rs | crate: common_utils use common_utils::{errors::PercentageError, types::Percentage}; fn valid_precision() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/tests/percentage.rs | crate: common_utils use common_utils::{errors::PercentageError, types::Percentage}; fn valid_range() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/tests/percentage.rs | crate: common_utils use common_utils::{errors::PercentageError, types::Percentage}; fn invalid_string() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/tests/percentage.rs | crate: common_utils use common_utils::{errors::PercentageError, types::Percentage}; fn invalid_range_less_than_0() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/common_utils/tests/percentage.rs | crate: common_utils use common_utils::{errors::PercentageError, types::Percentage}; fn invalid_range_more_than_100() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { let percentage = Percentage::<PRECISION_2>::from_string("100.01".to_string()); assert!(percentage.is_err()); if let Err(err) = percentage { assert_eq!( *err.current_context(), PercentageError::InvalidPercentageValue ) } Ok(()) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn get_required_value( self, field_name: &'static str, ) -> CustomResult<T, errors::ValidationError> { { Some(v) => Ok(v),<|fim_suffix|> <|fim_middle|> None => Err(errors::ValidationError::MissingRequiredField { field_name: field_name.to_string(), }) .attach_printable(format!("Missing required field {field_name} in {self:?}")), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn is_default_or_empty(&self) -> bool where T: Default + PartialEq<T>, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn update_value(&mut self, value: Self) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use quick_xml::de; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_value<U>(self, type_name: &'static str) -> CustomResult<U, errors::ParsingError> where T: ValueExt, U: serde::de::DeserializeOwned, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_enum<E>(self, enum_name: &'static str) -> CustomResult<E, errors::ParsingError> where T: AsRef<str>, E: std::str::FromStr, <E as std::str::FromStr>::Err: std::error::Error + Send + Sync + 'static, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn get_required_value( self, field_name: &'static str, ) -> CustomResult<T, errors::ValidationError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn check_value_present( &self, field_name: &'static str, ) -> CustomResult<(), errors::ValidationError> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use quick_xml::de; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_xml<T>(self) -> Result<T, de::DeError> where T: serde::de::DeserializeOwned, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn is_default_or_empty(&self) -> bool where T: Default + PartialEq<T>, { self.peek().is_default() || self.peek().is_empty_after_trim() }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn is_empty_after_trim(&self) -> bool { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn is_default(&self) -> bool where T: Default + PartialEq<T>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn is_empty_after_trim(&self) -> bool { self.trim().is_empty() }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; /// Returns whether the value of `self` is the default value for `Self` or empty after trimming /// whitespace on both left and right ends. fn is_default_or_empty(&self) -> bool where Self: Default + PartialEq<Self>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; /// Returns whether the value of `self` is the default value for `Self`. fn is_default(&self) -> bool where Self: Default + PartialEq<Self>, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; async fn async_map<F, B, Fut>(self, func: F) -> Self::WrappedSelf<B> where F: FnOnce(A) -> Fut + Send, Fut: futures::Future<Output = B> + Send, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; async fn async_and_then<F, B, Fut>(self, func: F) -> Self::WrappedSelf<B> where F: FnOnce(A) -> Fut + Send, Fut: futures::Future<Output = Self::WrappedSelf<B>> + Send, { { Some(a) => func(a).await,<|fim_suffix|> <|fim_middle|> None => None, } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use router_env::logger; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; async fn async_unwrap_or_else<F, Fut>(self, func: F) -> A where F: FnOnce() -> Fut + Send, Fut: futures::Future<Output = A> + Send, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; async fn async_map<F, B, Fut>(self, func: F) -> Self::WrappedSelf<B> where F: FnOnce(A) -> Fut + Send, Fut: futures::Future<Output = B> + Send, { { Ok(a) => Ok(func(a).await),<|fim_suffix|> <|fim_middle|> Err(err) => Err(err), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; async fn async_and_then<F, B, Fut>(self, func: F) -> Self::WrappedSelf<B> where F: FnOnce(A) -> Fut + Send, Fut: futures::Future<Output = Self::WrappedSelf<B>> + Send, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use quick_xml::de; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_struct<'de>( &'de self, type_name: &'static str, ) -> CustomResult<T, errors::ParsingError> where T: Deserialize<'de>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_enum(self, enum_name: &'static str) -> CustomResult<T, errors::ParsingError> where T: std::str::FromStr, <T as std::str::FromStr>::Err: std::error::Error + Send + Sync + 'static, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use quick_xml::de; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_value<T>(self, type_name: &'static str) -> CustomResult<T, errors::ParsingError> where T: serde::de::DeserializeOwned, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use quick_xml::de; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_value<T>(self, type_name: &'static str) -> CustomResult<T, errors::ParsingError> where T: serde::de::DeserializeOwned, { self.expose().parse_value(type_name) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use error_stack::ResultExt; use masking::{ExposeInterface, PeekInterface, Secret, Strategy}; use quick_xml::de; use router_env::logger; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn parse_struct<'de, T>( &'de self, type_name: &'static str, ) -> CustomResult<T, errors::ParsingError> where T: Deserialize<'de>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn encode_to_vec(&'e self) -> CustomResult<Vec<u8>, errors::ParsingError> where Self: Serialize, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn encode_to_value(&'e self) -> CustomResult<serde_json::Value, errors::ParsingError> where Self: Serialize, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use quick_xml::de; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn encode_to_string_of_xml(&'e self) -> CustomResult<String, errors::ParsingError> where Self: Serialize, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn encode_to_string_of_json(&'e self) -> CustomResult<String, errors::ParsingError> where Self: Serialize, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn url_encode(&'e self) -> CustomResult<String, errors::ParsingError> where Self: Serialize, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use error_stack::ResultExt; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn convert_and_url_encode<P>(&'e self) -> CustomResult<String, errors::ParsingError> where P: TryFrom<&'e Self> + Serialize, Result<P, <P as TryFrom<&'e Self>>::Error>: ResultExt, <Result<P, <P as TryFrom<&'e Self>>::Error> as ResultExt>::Ok: Serialize, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/ext_traits.rs | crate: common_utils use error_stack::ResultExt; use serde::{Deserialize, Serialize}; use crate::{ crypto, errors::{self, CustomResult}, fp_utils::when, }; fn convert_and_encode<P>(&'e self) -> CustomResult<String, errors::ParsingError> where P: TryFrom<&'e Self> + Serialize, Result<P, <P as TryFrom<&'e Self>>::Error>: ResultExt, <Result<P, <P as TryFrom<&'e Self>>::Error> as ResultExt>::Ok: Serialize, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn attach_default_headers(mut self) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn get_inner_value(&self) -> Secret<String> { { Self::Json(i) => serde_json::to_string(&i).unwrap_or_default().into(),<|fim_suffix|> <|fim_middle|> Self::RawBytes(_) => String::new().into(), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn build(self) -> Request { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn add_certificate_key(mut self, certificate_key: Option<Secret<String>>) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn add_certificate(mut self, certificate: Option<Secret<String>>) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn set_body<T: Into<RequestContent>>(mut self, body: T) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn set_optional_body<T: Into<RequestContent>>(mut self, body: Option<T>) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn headers(mut self, headers: Vec<(String, Maskable<String>)>) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn header(mut self, header: &str, value: &str) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn attach_default_headers(mut self) -> Self { self.headers.extend(default_request_headers()); self }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn method(mut self, method: Method) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn url(mut self, url: &str) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn add_certificate_key(&mut self, certificate_key: Option<Secret<String>>) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn add_certificate(&mut self, certificate: Option<Secret<String>>) { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn add_header(&mut self, header: &str, value: Maskable<String>) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn add_default_headers(&mut self) { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn set_body<T: Into<RequestContent>>(&mut self, body: T) { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn new(method: Method, url: &str) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; pub fn get_inner_value(&self) -> Secret<String> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/request.rs | crate: common_utils use masking::{Maskable, Secret}; use serde::{Deserialize, Serialize}; pub type Headers = std::collections::HashSet<(String, Maskable<String>)>; fn default_request_headers() -> [(String, Maskable<String>); 1] { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils fn amount_conversion_to_string_major_unit() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils fn amount_conversion_to_float_major_unit() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; use diesel::{ backend::Backend, deserialize, deserialize::FromSql, serialize::{Output, ToSql}, sql_types, sql_types::Jsonb, AsExpression, FromSqlRow, Queryable, }; pub use client_secret_type::ClientSecret; fn test_deserialize_client_secret() { {// This is a valid global id<|fim_suffix|> <|fim_middle|> assert_eq!( invalid_deser2.err().unwrap().to_string(), "invalid value: string \"123_pay_1a961ed9093c48b09781bf8ab17ba6bd\", expected a string with '_secret_' at line 1 column 42" );}}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use serde::{de::Visitor, Deserialize, Deserializer, Serialize}; use thiserror::Error; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de>, { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use error_stack::{report, ResultExt}; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Implementation for retrieving pub fn get_txn_id<'a>( &'a self, txn_data: Option<&'a String>, ) -> Result<&'a String, error_stack::Report<ValidationError>> { { (Self::TxnId(id), _) => Ok(id),<|fim_suffix|> <|fim_middle|> (Self::HashedData(id), None) => Err(report!(ValidationError::InvalidValue { message: "processor_transaction_data is empty for HashedData variant".to_string(), }) .attach_printable(format!( "processor_transaction_data is empty for connector_transaction_id {}", id ))), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; pub use client_secret_type::ClientSecret; /// Implementation for forming ConnectorTransactionId and an optional string to be used for connector_transaction_id and processor_transaction_data pub fn form_id_and_data(src: String) -> (Self, Option<String>) { { Self::TxnId(_) => (txn_id, None),<|fim_suffix|> <|fim_middle|> Self::HashedData(_) => (txn_id, Some(src)), } }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use diesel::{ backend::Backend, deserialize, deserialize::FromSql, serialize::{Output, ToSql}, sql_types, sql_types::Jsonb, AsExpression, FromSqlRow, Queryable, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> diesel::serialize::Result { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use diesel::{ backend::Backend, deserialize, deserialize::FromSql, serialize::{Output, ToSql}, sql_types, sql_types::Jsonb, AsExpression, FromSqlRow, Queryable, }; fn build(row: Self::Row) -> deserialize::Result<Self> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Get the string representation of the PublishableKey pub fn get_string_repr(&self) -> &str { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; pub use client_secret_type::ClientSecret; /// Create a new PublishableKey Domain type without any length check from a static str pub fn generate(env_prefix: &'static str) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; /// Returns an optional connector refund ID fn get_optional_connector_refund_id(&self) -> Option<&String> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; /// Returns a connector transaction ID fn get_connector_transaction_id(&self) -> &String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; /// Returns an optional connector transaction ID fn get_optional_connector_transaction_id(&self) -> Option<&String> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use error_stack::{report, ResultExt}; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Implementation for retrieving pub fn get_txn_id<'a>( &'a self, txn_data: Option<&'a String>, ) -> Result<&'a String, error_stack::Report<ValidationError>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; pub use client_secret_type::ClientSecret; /// Implementation for forming ConnectorTransactionId and an optional string to be used for connector_transaction_id and processor_transaction_data pub fn form_id_and_data(src: String) -> (Self, Option<String>) { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Implementation for retrieving the inner identifier pub fn get_id(&self) -> &String { match self { Self::TxnId(id) | Self::HashedData(id) => id, } }
ast_fragments
// file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use diesel::{ backend::Backend, deserialize, deserialize::FromSql, serialize::{Output, ToSql}, sql_types, sql_types::Jsonb, AsExpression, FromSqlRow, Queryable, }; fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result<Self> { let val = String::from_sql(bytes)?; Ok(Self::try_from(val)?) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use error_stack::{report, ResultExt}; use thiserror::Error; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; fn try_from(src: String) -> Result<Self, Self::Error> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
// file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use diesel::{ backend::Backend, deserialize, deserialize::FromSql, serialize::{Output, ToSql}, sql_types, sql_types::Jsonb, AsExpression, FromSqlRow, Queryable, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> diesel::serialize::Result { self.0.to_sql(out) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Get the string representation of the description pub fn get_string_repr(&self) -> &str { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; pub use client_secret_type::ClientSecret; /// Create a new Description Domain type without any length check from a static str pub fn from_str_unchecked(input_str: &'static str) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; pub(crate) fn new_unchecked(input_string: String) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Generates new [MerchantReferenceId] from the given input string pub fn from(input_string: Cow<'static, str>) -> Result<Self, LengthStringError> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils fn amount_conversion_to_string_minor_unit() { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; use diesel::{ backend::Backend, deserialize, deserialize::FromSql, serialize::{Output, ToSql}, sql_types, sql_types::Jsonb, AsExpression, FromSqlRow, Queryable, }; pub use client_secret_type::ClientSecret; fn test_serialize_client_secret() { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; use serde::{de::Visitor, Deserialize, Deserializer, Serialize}; use thiserror::Error; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; fn visit_str<E>(self, value: &str) -> Result<ClientSecret, E> where E: serde::de::Error, { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
// file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("a string in the format '{payment_id}_secret_{secret}'") }
ast_fragments
// file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; use thiserror::Error; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; fn from_str(str_value: &str) -> Result<Self, Self::Err> { let (payment_id, secret) = str_value .rsplit_once("_secret_") .ok_or(ParsingError::EncodeError( "Expected a string in the format '{payment_id}_secret_{secret}'", ))?; let payment_id = id_type::GlobalPaymentId::try_from(Cow::Owned(payment_id.to_owned())) .map_err(|err| { logger::error!(global_payment_id_error=?err); ParsingError::EncodeError("Error while constructing GlobalPaymentId") })?; Ok(Self { payment_id, secret: masking::Secret::new(secret.to_owned()), }) }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Create a new client secret pub(crate) fn new(payment_id: id_type::GlobalPaymentId, secret: String) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; pub(crate) fn get_string_repr(&self) -> String { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Add query params to the url pub fn add_query_params(mut self, (key, value): (&str, &str)) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Get the inner url pub fn into_inner(self) -> url::Url { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; pub use client_secret_type::ClientSecret; /// wrap the url::Url in Url type pub fn wrap(url: url::Url) -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use std::{ borrow::Cow, fmt::Display, iter::Sum, ops::{Add, Mul, Sub}, primitive::i64, str::FromStr, }; pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Get string representation of the url pub fn get_string_repr(&self) -> &str { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; pub use client_secret_type::ClientSecret; /// Get string amount from struct to be removed in future pub fn get_amount_as_string(&self) -> String { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; pub use client_secret_type::ClientSecret; /// forms a new StringMajorUnit default unit i.e zero pub fn zero() -> Self { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use common_enums::enums; use error_stack::{report, ResultExt}; use rust_decimal::{ prelude::{FromPrimitive, ToPrimitive}, Decimal, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; /// Converts to minor unit as i64 from StringMajorUnit fn to_minor_unit_as_i64( &self, currency: enums::Currency, ) -> Result<MinorUnit, error_stack::Report<ParsingError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils /// forms a new major unit from amount fn new(value: String) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use common_enums::enums; use error_stack::{report, ResultExt}; use rust_decimal::{ prelude::{FromPrimitive, ToPrimitive}, Decimal, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; /// converts to minor unit as i64 from FloatMajorUnit fn to_minor_unit_as_i64( self, currency: enums::Currency, ) -> Result<MinorUnit, error_stack::Report<ParsingError>> { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils pub use primitive_wrappers::bool_wrappers::{ AlwaysRequestExtendedAuthorization, ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool, }; pub use client_secret_type::ClientSecret; /// forms a new major unit with zero amount pub fn zero() -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils /// forms a new major unit from amount fn new(value: f64) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils use error_stack::{report, ResultExt}; use rust_decimal::{ prelude::{FromPrimitive, ToPrimitive}, Decimal, }; use crate::{ consts::{ self, MAX_DESCRIPTION_LENGTH, MAX_STATEMENT_DESCRIPTOR_LENGTH, PUBLISHABLE_KEY_LENGTH, }, errors::{CustomResult, ParsingError, PercentageError, ValidationError}, fp_utils::when, }; /// converts to minor unit i64 from minor unit string value fn to_minor_unit_as_i64(&self) -> Result<MinorUnit, error_stack::Report<ParsingError>> { {<|fim_suffix|> <|fim_middle|> }}
ast_fragments
<|fim_prefix|> // file: hyperswitch/crates/common_utils/src/types.rs | crate: common_utils /// forms a new minor unit in string from amount fn new(value: String) -> Self { <|fim_suffix|> <|fim_middle|> }
ast_fragments