id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
connector-service_snippet_1414821583984559341_100_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
fn convert_back(
&self,
amount: StringMajorUnit,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
amount.to_minor_unit_as_i64(currency)
}
}
/// Connector required amount type
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct FloatMajorUnitForConnector;
impl AmountConvertor for FloatMajorUnitForConnector {
type Output = FloatMajorUnit;
fn convert(
&self,
amount: MinorUnit,
currency: enums::Currency,
) -> Result<Self::Output, error_stack::Report<ParsingError>> {
amount.to_major_unit_as_f64(currency)
}
fn convert_back(
&self,
amount: FloatMajorUnit,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
amount.to_minor_unit_as_i64(currency)
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 100,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_100_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
fn convert_back(
&self,
amount: StringMajorUnit,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
amount.to_minor_unit_as_i64(currency)
}
}
/// Connector required amount type
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct FloatMajorUnitForConnector;
impl AmountConvertor for FloatMajorUnitForConnector {
type Output = FloatMajorUnit;
fn convert(
&self,
amount: MinorUnit,
currency: enums::Currency,
) -> Result<Self::Output, error_stack::Report<ParsingError>> {
amount.to_major_unit_as_f64(currency)
}
fn convert_back(
&self,
amount: FloatMajorUnit,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
amount.to_minor_unit_as_i64(currency)
}
}
/// Connector required amount type
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct MinorUnitForConnector;
impl AmountConvertor for MinorUnitForConnector {
type Output = MinorUnit;
fn convert(
&self,
amount: MinorUnit,
_currency: enums::Currency,
) -> Result<Self::Output, error_stack::Report<ParsingError>> {
Ok(amount)
}
fn convert_back(
&self,
amount: MinorUnit,
_currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 100,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_125_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
amount: FloatMajorUnit,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
amount.to_minor_unit_as_i64(currency)
}
}
/// Connector required amount type
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct MinorUnitForConnector;
impl AmountConvertor for MinorUnitForConnector {
type Output = MinorUnit;
fn convert(
&self,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 125,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_125_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
amount: FloatMajorUnit,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
amount.to_minor_unit_as_i64(currency)
}
}
/// Connector required amount type
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct MinorUnitForConnector;
impl AmountConvertor for MinorUnitForConnector {
type Output = MinorUnit;
fn convert(
&self,
amount: MinorUnit,
_currency: enums::Currency,
) -> Result<Self::Output, error_stack::Report<ParsingError>> {
Ok(amount)
}
fn convert_back(
&self,
amount: MinorUnit,
_currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
Ok(amount)
}
}
/// This Unit struct represents MinorUnit in which core amount works
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 125,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_125_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
amount: FloatMajorUnit,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
amount.to_minor_unit_as_i64(currency)
}
}
/// Connector required amount type
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct MinorUnitForConnector;
impl AmountConvertor for MinorUnitForConnector {
type Output = MinorUnit;
fn convert(
&self,
amount: MinorUnit,
_currency: enums::Currency,
) -> Result<Self::Output, error_stack::Report<ParsingError>> {
Ok(amount)
}
fn convert_back(
&self,
amount: MinorUnit,
_currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
Ok(amount)
}
}
/// This Unit struct represents MinorUnit in which core amount works
#[derive(
Default,
Debug,
serde::Deserialize,
serde::Serialize,
Clone,
Copy,
PartialEq,
Eq,
Hash,
ToSchema,
PartialOrd,
)]
pub struct MinorUnit(pub i64);
impl MinorUnit {
/// gets amount as i64 value will be removed in future
pub fn get_amount_as_i64(self) -> i64 {
self.0
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 125,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_150_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
Ok(amount)
}
}
/// This Unit struct represents MinorUnit in which core amount works
#[derive(
Default,
Debug,
serde::Deserialize,
serde::Serialize,
Clone,
Copy,
PartialEq,
Eq,
Hash,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 150,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_150_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
Ok(amount)
}
}
/// This Unit struct represents MinorUnit in which core amount works
#[derive(
Default,
Debug,
serde::Deserialize,
serde::Serialize,
Clone,
Copy,
PartialEq,
Eq,
Hash,
ToSchema,
PartialOrd,
)]
pub struct MinorUnit(pub i64);
impl MinorUnit {
/// gets amount as i64 value will be removed in future
pub fn get_amount_as_i64(self) -> i64 {
self.0
}
/// forms a new minor default unit i.e zero
pub fn zero() -> Self {
Self(0)
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 150,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_150_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
Ok(amount)
}
}
/// This Unit struct represents MinorUnit in which core amount works
#[derive(
Default,
Debug,
serde::Deserialize,
serde::Serialize,
Clone,
Copy,
PartialEq,
Eq,
Hash,
ToSchema,
PartialOrd,
)]
pub struct MinorUnit(pub i64);
impl MinorUnit {
/// gets amount as i64 value will be removed in future
pub fn get_amount_as_i64(self) -> i64 {
self.0
}
/// forms a new minor default unit i.e zero
pub fn zero() -> Self {
Self(0)
}
/// forms a new minor unit from amount
pub fn new(value: i64) -> Self {
Self(value)
}
/// checks if the amount is greater than the given value
pub fn is_greater_than(&self, value: i64) -> bool {
self.get_amount_as_i64() > value
}
/// Convert the amount to its major denomination based on Currency and return String
/// This method now validates currency support and will error for unsupported currencies.
/// Paypal Connector accepts Zero and Two decimal currency but not three decimal and it should be updated as required for 3 decimal currencies.
/// Paypal Ref - https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/
fn to_major_unit_as_string(
self,
currency: enums::Currency,
) -> Result<StringMajorUnit, error_stack::Report<ParsingError>> {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 150,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_175_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
}
/// forms a new minor default unit i.e zero
pub fn zero() -> Self {
Self(0)
}
/// forms a new minor unit from amount
pub fn new(value: i64) -> Self {
Self(value)
}
/// checks if the amount is greater than the given value
pub fn is_greater_than(&self, value: i64) -> bool {
self.get_amount_as_i64() > value
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 175,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_175_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
}
/// forms a new minor default unit i.e zero
pub fn zero() -> Self {
Self(0)
}
/// forms a new minor unit from amount
pub fn new(value: i64) -> Self {
Self(value)
}
/// checks if the amount is greater than the given value
pub fn is_greater_than(&self, value: i64) -> bool {
self.get_amount_as_i64() > value
}
/// Convert the amount to its major denomination based on Currency and return String
/// This method now validates currency support and will error for unsupported currencies.
/// Paypal Connector accepts Zero and Two decimal currency but not three decimal and it should be updated as required for 3 decimal currencies.
/// Paypal Ref - https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/
fn to_major_unit_as_string(
self,
currency: enums::Currency,
) -> Result<StringMajorUnit, error_stack::Report<ParsingError>> {
let amount_f64 = self.to_major_unit_as_f64(currency)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 175,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_175_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
}
/// forms a new minor default unit i.e zero
pub fn zero() -> Self {
Self(0)
}
/// forms a new minor unit from amount
pub fn new(value: i64) -> Self {
Self(value)
}
/// checks if the amount is greater than the given value
pub fn is_greater_than(&self, value: i64) -> bool {
self.get_amount_as_i64() > value
}
/// Convert the amount to its major denomination based on Currency and return String
/// This method now validates currency support and will error for unsupported currencies.
/// Paypal Connector accepts Zero and Two decimal currency but not three decimal and it should be updated as required for 3 decimal currencies.
/// Paypal Ref - https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/
fn to_major_unit_as_string(
self,
currency: enums::Currency,
) -> Result<StringMajorUnit, error_stack::Report<ParsingError>> {
let amount_f64 = self.to_major_unit_as_f64(currency)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount_string = if decimal_places == 0 {
amount_f64.0.to_string()
} else if decimal_places == 3 {
format!("{:.3}", amount_f64.0)
} else if decimal_places == 4 {
format!("{:.4}", amount_f64.0)
} else {
format!("{:.2}", amount_f64.0) // 2 decimal places
};
Ok(StringMajorUnit::new(amount_string))
}
/// Convert the amount to its major denomination based on Currency and return f64
/// This method now validates currency support and will error for unsupported currencies.
fn to_major_unit_as_f64(
self,
currency: enums::Currency,
) -> Result<FloatMajorUnit, error_stack::Report<ParsingError>> {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 175,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_200_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
let amount_f64 = self.to_major_unit_as_f64(currency)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount_string = if decimal_places == 0 {
amount_f64.0.to_string()
} else if decimal_places == 3 {
format!("{:.3}", amount_f64.0)
} else if decimal_places == 4 {
format!("{:.4}", amount_f64.0)
} else {
format!("{:.2}", amount_f64.0) // 2 decimal places
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 200,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_200_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
let amount_f64 = self.to_major_unit_as_f64(currency)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount_string = if decimal_places == 0 {
amount_f64.0.to_string()
} else if decimal_places == 3 {
format!("{:.3}", amount_f64.0)
} else if decimal_places == 4 {
format!("{:.4}", amount_f64.0)
} else {
format!("{:.2}", amount_f64.0) // 2 decimal places
};
Ok(StringMajorUnit::new(amount_string))
}
/// Convert the amount to its major denomination based on Currency and return f64
/// This method now validates currency support and will error for unsupported currencies.
fn to_major_unit_as_f64(
self,
currency: enums::Currency,
) -> Result<FloatMajorUnit, error_stack::Report<ParsingError>> {
let amount_decimal =
Decimal::from_i64(self.0).ok_or(ParsingError::I64ToDecimalConversionFailure)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 200,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_200_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
let amount_f64 = self.to_major_unit_as_f64(currency)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount_string = if decimal_places == 0 {
amount_f64.0.to_string()
} else if decimal_places == 3 {
format!("{:.3}", amount_f64.0)
} else if decimal_places == 4 {
format!("{:.4}", amount_f64.0)
} else {
format!("{:.2}", amount_f64.0) // 2 decimal places
};
Ok(StringMajorUnit::new(amount_string))
}
/// Convert the amount to its major denomination based on Currency and return f64
/// This method now validates currency support and will error for unsupported currencies.
fn to_major_unit_as_f64(
self,
currency: enums::Currency,
) -> Result<FloatMajorUnit, error_stack::Report<ParsingError>> {
let amount_decimal =
Decimal::from_i64(self.0).ok_or(ParsingError::I64ToDecimalConversionFailure)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount = if decimal_places == 0 {
amount_decimal
} else if decimal_places == 3 {
amount_decimal / Decimal::from(1000)
} else if decimal_places == 4 {
amount_decimal / Decimal::from(10000)
} else {
amount_decimal / Decimal::from(100) // 2 decimal places
};
let amount_f64 = amount
.to_f64()
.ok_or(ParsingError::FloatToDecimalConversionFailure)?;
Ok(FloatMajorUnit::new(amount_f64))
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 200,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_225_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
let amount_decimal =
Decimal::from_i64(self.0).ok_or(ParsingError::I64ToDecimalConversionFailure)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount = if decimal_places == 0 {
amount_decimal
} else if decimal_places == 3 {
amount_decimal / Decimal::from(1000)
} else if decimal_places == 4 {
amount_decimal / Decimal::from(10000)
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 225,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_225_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
let amount_decimal =
Decimal::from_i64(self.0).ok_or(ParsingError::I64ToDecimalConversionFailure)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount = if decimal_places == 0 {
amount_decimal
} else if decimal_places == 3 {
amount_decimal / Decimal::from(1000)
} else if decimal_places == 4 {
amount_decimal / Decimal::from(10000)
} else {
amount_decimal / Decimal::from(100) // 2 decimal places
};
let amount_f64 = amount
.to_f64()
.ok_or(ParsingError::FloatToDecimalConversionFailure)?;
Ok(FloatMajorUnit::new(amount_f64))
}
///Convert minor unit to string minor unit
fn to_minor_unit_as_string(self) -> Result<StringMinorUnit, error_stack::Report<ParsingError>> {
Ok(StringMinorUnit::new(self.0.to_string()))
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 225,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_225_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
let amount_decimal =
Decimal::from_i64(self.0).ok_or(ParsingError::I64ToDecimalConversionFailure)?;
let decimal_places = currency
.number_of_digits_after_decimal_point()
.change_context(ParsingError::StructParseFailure(
"currency decimal configuration",
))?;
let amount = if decimal_places == 0 {
amount_decimal
} else if decimal_places == 3 {
amount_decimal / Decimal::from(1000)
} else if decimal_places == 4 {
amount_decimal / Decimal::from(10000)
} else {
amount_decimal / Decimal::from(100) // 2 decimal places
};
let amount_f64 = amount
.to_f64()
.ok_or(ParsingError::FloatToDecimalConversionFailure)?;
Ok(FloatMajorUnit::new(amount_f64))
}
///Convert minor unit to string minor unit
fn to_minor_unit_as_string(self) -> Result<StringMinorUnit, error_stack::Report<ParsingError>> {
Ok(StringMinorUnit::new(self.0.to_string()))
}
}
impl Display for MinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl Add for MinorUnit {
type Output = Self;
fn add(self, a2: Self) -> Self {
Self(self.0 + a2.0)
}
}
impl Sub for MinorUnit {
type Output = Self;
fn sub(self, a2: Self) -> Self {
Self(self.0 - a2.0)
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 225,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_250_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
///Convert minor unit to string minor unit
fn to_minor_unit_as_string(self) -> Result<StringMinorUnit, error_stack::Report<ParsingError>> {
Ok(StringMinorUnit::new(self.0.to_string()))
}
}
impl Display for MinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl Add for MinorUnit {
type Output = Self;
fn add(self, a2: Self) -> Self {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 250,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_250_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
///Convert minor unit to string minor unit
fn to_minor_unit_as_string(self) -> Result<StringMinorUnit, error_stack::Report<ParsingError>> {
Ok(StringMinorUnit::new(self.0.to_string()))
}
}
impl Display for MinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl Add for MinorUnit {
type Output = Self;
fn add(self, a2: Self) -> Self {
Self(self.0 + a2.0)
}
}
impl Sub for MinorUnit {
type Output = Self;
fn sub(self, a2: Self) -> Self {
Self(self.0 - a2.0)
}
}
impl Mul<u16> for MinorUnit {
type Output = Self;
fn mul(self, a2: u16) -> Self::Output {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 250,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_250_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
///Convert minor unit to string minor unit
fn to_minor_unit_as_string(self) -> Result<StringMinorUnit, error_stack::Report<ParsingError>> {
Ok(StringMinorUnit::new(self.0.to_string()))
}
}
impl Display for MinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl Add for MinorUnit {
type Output = Self;
fn add(self, a2: Self) -> Self {
Self(self.0 + a2.0)
}
}
impl Sub for MinorUnit {
type Output = Self;
fn sub(self, a2: Self) -> Self {
Self(self.0 - a2.0)
}
}
impl Mul<u16> for MinorUnit {
type Output = Self;
fn mul(self, a2: u16) -> Self::Output {
Self(self.0 * i64::from(a2))
}
}
impl Sum for MinorUnit {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Self(0), |a, b| a + b)
}
}
/// Connector specific types to send
#[derive(
Default,
Debug,
serde::Deserialize,
serde::Serialize,
Clone,
PartialEq,
Eq,
Hash,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 250,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_275_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
impl Mul<u16> for MinorUnit {
type Output = Self;
fn mul(self, a2: u16) -> Self::Output {
Self(self.0 * i64::from(a2))
}
}
impl Sum for MinorUnit {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Self(0), |a, b| a + b)
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 275,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_275_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
impl Mul<u16> for MinorUnit {
type Output = Self;
fn mul(self, a2: u16) -> Self::Output {
Self(self.0 * i64::from(a2))
}
}
impl Sum for MinorUnit {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Self(0), |a, b| a + b)
}
}
/// Connector specific types to send
#[derive(
Default,
Debug,
serde::Deserialize,
serde::Serialize,
Clone,
PartialEq,
Eq,
Hash,
ToSchema,
PartialOrd,
)]
pub struct StringMinorUnit(String);
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 275,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_275_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
impl Mul<u16> for MinorUnit {
type Output = Self;
fn mul(self, a2: u16) -> Self::Output {
Self(self.0 * i64::from(a2))
}
}
impl Sum for MinorUnit {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Self(0), |a, b| a + b)
}
}
/// Connector specific types to send
#[derive(
Default,
Debug,
serde::Deserialize,
serde::Serialize,
Clone,
PartialEq,
Eq,
Hash,
ToSchema,
PartialOrd,
)]
pub struct StringMinorUnit(String);
impl StringMinorUnit {
/// forms a new minor unit in string from amount
fn new(value: String) -> Self {
Self(value)
}
/// converts to minor unit i64 from minor unit string value
fn to_minor_unit_as_i64(&self) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_string = &self.0;
let amount_decimal = Decimal::from_str(amount_string).map_err(|e| {
ParsingError::StringToDecimalConversionFailure {
error: e.to_string(),
}
})?;
let amount_i64 = amount_decimal
.to_i64()
.ok_or(ParsingError::DecimalToI64ConversionFailure)?;
Ok(MinorUnit::new(amount_i64))
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 275,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_300_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
ToSchema,
PartialOrd,
)]
pub struct StringMinorUnit(String);
impl StringMinorUnit {
/// forms a new minor unit in string from amount
fn new(value: String) -> Self {
Self(value)
}
/// converts to minor unit i64 from minor unit string value
fn to_minor_unit_as_i64(&self) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_string = &self.0;
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 300,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_300_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
ToSchema,
PartialOrd,
)]
pub struct StringMinorUnit(String);
impl StringMinorUnit {
/// forms a new minor unit in string from amount
fn new(value: String) -> Self {
Self(value)
}
/// converts to minor unit i64 from minor unit string value
fn to_minor_unit_as_i64(&self) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_string = &self.0;
let amount_decimal = Decimal::from_str(amount_string).map_err(|e| {
ParsingError::StringToDecimalConversionFailure {
error: e.to_string(),
}
})?;
let amount_i64 = amount_decimal
.to_i64()
.ok_or(ParsingError::DecimalToI64ConversionFailure)?;
Ok(MinorUnit::new(amount_i64))
}
}
impl Display for StringMinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 300,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_300_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
ToSchema,
PartialOrd,
)]
pub struct StringMinorUnit(String);
impl StringMinorUnit {
/// forms a new minor unit in string from amount
fn new(value: String) -> Self {
Self(value)
}
/// converts to minor unit i64 from minor unit string value
fn to_minor_unit_as_i64(&self) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_string = &self.0;
let amount_decimal = Decimal::from_str(amount_string).map_err(|e| {
ParsingError::StringToDecimalConversionFailure {
error: e.to_string(),
}
})?;
let amount_i64 = amount_decimal
.to_i64()
.ok_or(ParsingError::DecimalToI64ConversionFailure)?;
Ok(MinorUnit::new(amount_i64))
}
}
impl Display for StringMinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
/// Connector specific types to send
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct FloatMajorUnit(pub f64);
impl FloatMajorUnit {
/// forms a new major unit from amount
fn new(value: f64) -> Self {
Self(value)
}
/// forms a new major unit with zero amount
pub fn zero() -> Self {
Self(0.0)
}
/// converts to minor unit as i64 from FloatMajorUnit
fn to_minor_unit_as_i64(
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 300,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_325_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
}
impl Display for StringMinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
/// Connector specific types to send
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct FloatMajorUnit(pub f64);
impl FloatMajorUnit {
/// forms a new major unit from amount
fn new(value: f64) -> Self {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 325,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_325_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
}
impl Display for StringMinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
/// Connector specific types to send
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct FloatMajorUnit(pub f64);
impl FloatMajorUnit {
/// forms a new major unit from amount
fn new(value: f64) -> Self {
Self(value)
}
/// forms a new major unit with zero amount
pub fn zero() -> Self {
Self(0.0)
}
/// converts to minor unit as i64 from FloatMajorUnit
fn to_minor_unit_as_i64(
self,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_decimal =
Decimal::from_f64(self.0).ok_or(ParsingError::FloatToDecimalConversionFailure)?;
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 325,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_325_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
}
impl Display for StringMinorUnit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
/// Connector specific types to send
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)]
pub struct FloatMajorUnit(pub f64);
impl FloatMajorUnit {
/// forms a new major unit from amount
fn new(value: f64) -> Self {
Self(value)
}
/// forms a new major unit with zero amount
pub fn zero() -> Self {
Self(0.0)
}
/// converts to minor unit as i64 from FloatMajorUnit
fn to_minor_unit_as_i64(
self,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_decimal =
Decimal::from_f64(self.0).ok_or(ParsingError::FloatToDecimalConversionFailure)?;
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))
}
}
/// Connector specific types to send
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq, Eq)]
pub struct StringMajorUnit(String);
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 325,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_350_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
self,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_decimal =
Decimal::from_f64(self.0).ok_or(ParsingError::FloatToDecimalConversionFailure)?;
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
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 350,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_350_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
self,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_decimal =
Decimal::from_f64(self.0).ok_or(ParsingError::FloatToDecimalConversionFailure)?;
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))
}
}
/// Connector specific types to send
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq, Eq)]
pub struct StringMajorUnit(String);
impl StringMajorUnit {
/// forms a new major unit from amount
fn new(value: String) -> Self {
Self(value)
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 350,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_350_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
self,
currency: enums::Currency,
) -> Result<MinorUnit, error_stack::Report<ParsingError>> {
let amount_decimal =
Decimal::from_f64(self.0).ok_or(ParsingError::FloatToDecimalConversionFailure)?;
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))
}
}
/// Connector specific types to send
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq, Eq)]
pub struct StringMajorUnit(String);
impl StringMajorUnit {
/// forms a new major unit from amount
fn new(value: String) -> Self {
Self(value)
}
/// Converts to minor unit as i64 from 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
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 350,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_375_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
impl StringMajorUnit {
/// forms a new major unit from amount
fn new(value: String) -> Self {
Self(value)
}
/// Converts to minor unit as i64 from 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(),
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 375,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_375_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
impl StringMajorUnit {
/// forms a new major unit from amount
fn new(value: String) -> Self {
Self(value)
}
/// Converts to minor unit as i64 from 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))
}
/// forms a new StringMajorUnit default unit i.e zero
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 375,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_375_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
impl StringMajorUnit {
/// forms a new major unit from amount
fn new(value: String) -> Self {
Self(value)
}
/// Converts to minor unit as i64 from 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))
}
/// forms a new StringMajorUnit default unit i.e zero
pub fn zero() -> Self {
Self("0".to_string())
}
/// Get string amount from struct to be removed in future
pub fn get_amount_as_string(&self) -> String {
self.0.clone()
}
}
/// A type representing a range of time for filtering, including a mandatory start time and an optional end time.
#[derive(
Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash, ToSchema,
)]
pub struct TimeRange {
/// The start time to filter payments list or to get list of filters. To get list of filters start time is needed to be passed
#[serde(with = "crate::custom_serde::iso8601")]
#[serde(alias = "startTime")]
pub start_time: PrimitiveDateTime,
/// The end time to filter payments list or to get list of filters. If not passed the default time is now
#[serde(default, with = "crate::custom_serde::iso8601::option")]
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 375,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_400_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
.to_i64()
.ok_or(ParsingError::DecimalToI64ConversionFailure)?;
Ok(MinorUnit::new(amount_i64))
}
/// forms a new StringMajorUnit default unit i.e zero
pub fn zero() -> Self {
Self("0".to_string())
}
/// Get string amount from struct to be removed in future
pub fn get_amount_as_string(&self) -> String {
self.0.clone()
}
}
/// A type representing a range of time for filtering, including a mandatory start time and an optional end time.
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 400,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_400_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
.to_i64()
.ok_or(ParsingError::DecimalToI64ConversionFailure)?;
Ok(MinorUnit::new(amount_i64))
}
/// forms a new StringMajorUnit default unit i.e zero
pub fn zero() -> Self {
Self("0".to_string())
}
/// Get string amount from struct to be removed in future
pub fn get_amount_as_string(&self) -> String {
self.0.clone()
}
}
/// A type representing a range of time for filtering, including a mandatory start time and an optional end time.
#[derive(
Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash, ToSchema,
)]
pub struct TimeRange {
/// The start time to filter payments list or to get list of filters. To get list of filters start time is needed to be passed
#[serde(with = "crate::custom_serde::iso8601")]
#[serde(alias = "startTime")]
pub start_time: PrimitiveDateTime,
/// The end time to filter payments list or to get list of filters. If not passed the default time is now
#[serde(default, with = "crate::custom_serde::iso8601::option")]
#[serde(alias = "endTime")]
pub end_time: Option<PrimitiveDateTime>,
}
/// This struct lets us represent a semantic version type
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 400,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_400_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
.to_i64()
.ok_or(ParsingError::DecimalToI64ConversionFailure)?;
Ok(MinorUnit::new(amount_i64))
}
/// forms a new StringMajorUnit default unit i.e zero
pub fn zero() -> Self {
Self("0".to_string())
}
/// Get string amount from struct to be removed in future
pub fn get_amount_as_string(&self) -> String {
self.0.clone()
}
}
/// A type representing a range of time for filtering, including a mandatory start time and an optional end time.
#[derive(
Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash, ToSchema,
)]
pub struct TimeRange {
/// The start time to filter payments list or to get list of filters. To get list of filters start time is needed to be passed
#[serde(with = "crate::custom_serde::iso8601")]
#[serde(alias = "startTime")]
pub start_time: PrimitiveDateTime,
/// The end time to filter payments list or to get list of filters. If not passed the default time is now
#[serde(default, with = "crate::custom_serde::iso8601::option")]
#[serde(alias = "endTime")]
pub end_time: Option<PrimitiveDateTime>,
}
/// This struct lets us represent a semantic version type
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, serde::Deserialize)]
pub struct SemanticVersion(#[serde(with = "Version")] Version);
impl SemanticVersion {
/// returns major version number
pub fn get_major(&self) -> u64 {
self.0.major
}
/// returns minor version number
pub fn get_minor(&self) -> u64 {
self.0.minor
}
/// Constructs new SemanticVersion instance
pub fn new(major: u64, minor: u64, patch: u64) -> Self {
Self(Version::new(major, minor, patch))
}
}
impl Display for SemanticVersion {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 400,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_425_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
#[serde(alias = "endTime")]
pub end_time: Option<PrimitiveDateTime>,
}
/// This struct lets us represent a semantic version type
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, serde::Deserialize)]
pub struct SemanticVersion(#[serde(with = "Version")] Version);
impl SemanticVersion {
/// returns major version number
pub fn get_major(&self) -> u64 {
self.0.major
}
/// returns minor version number
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 425,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_425_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
#[serde(alias = "endTime")]
pub end_time: Option<PrimitiveDateTime>,
}
/// This struct lets us represent a semantic version type
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, serde::Deserialize)]
pub struct SemanticVersion(#[serde(with = "Version")] Version);
impl SemanticVersion {
/// returns major version number
pub fn get_major(&self) -> u64 {
self.0.major
}
/// returns minor version number
pub fn get_minor(&self) -> u64 {
self.0.minor
}
/// Constructs new SemanticVersion instance
pub fn new(major: u64, minor: u64, patch: u64) -> Self {
Self(Version::new(major, minor, patch))
}
}
impl Display for SemanticVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 425,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_425_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
#[serde(alias = "endTime")]
pub end_time: Option<PrimitiveDateTime>,
}
/// This struct lets us represent a semantic version type
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd, Serialize, serde::Deserialize)]
pub struct SemanticVersion(#[serde(with = "Version")] Version);
impl SemanticVersion {
/// returns major version number
pub fn get_major(&self) -> u64 {
self.0.major
}
/// returns minor version number
pub fn get_minor(&self) -> u64 {
self.0.minor
}
/// Constructs new SemanticVersion instance
pub fn new(major: u64, minor: u64, patch: u64) -> Self {
Self(Version::new(major, minor, patch))
}
}
impl Display for SemanticVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl FromStr for SemanticVersion {
type Err = error_stack::Report<ParsingError>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(Version::from_str(s).change_context(
ParsingError::StructParseFailure("SemanticVersion"),
)?))
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 39,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 425,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_450_15 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl FromStr for SemanticVersion {
type Err = error_stack::Report<ParsingError>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(Version::from_str(s).change_context(
ParsingError::StructParseFailure("SemanticVersion"),
)?))
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 14,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 450,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_450_30 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl FromStr for SemanticVersion {
type Err = error_stack::Report<ParsingError>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(Version::from_str(s).change_context(
ParsingError::StructParseFailure("SemanticVersion"),
)?))
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 14,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 450,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_1414821583984559341_450_50 | clm | snippet | // connector-service/backend/common_utils/src/types.rs
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl FromStr for SemanticVersion {
type Err = error_stack::Report<ParsingError>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(Version::from_str(s).change_context(
ParsingError::StructParseFailure("SemanticVersion"),
)?))
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 14,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 450,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_0_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::{
global_id::{
customer::GlobalCustomerId,
payment::GlobalPaymentId,
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
token::GlobalTokenId,
},
id_type::{self, ApiKeyId, MerchantConnectorAccountId, ProfileAcquirerId},
lineage,
types::TimeRange,
};
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 0,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_0_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::{
global_id::{
customer::GlobalCustomerId,
payment::GlobalPaymentId,
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
token::GlobalTokenId,
},
id_type::{self, ApiKeyId, MerchantConnectorAccountId, ProfileAcquirerId},
lineage,
types::TimeRange,
};
/// Wrapper type that enforces masked serialization for Serde values
#[derive(Debug, Clone, Serialize)]
#[serde(transparent)]
pub struct MaskedSerdeValue {
inner: serde_json::Value,
}
impl MaskedSerdeValue {
pub fn from_masked<T: Serialize>(value: &T) -> Result<Self, serde_json::Error> {
let masked_value = hyperswitch_masking::masked_serialize(value)?;
Ok(Self {
inner: masked_value,
})
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 0,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_0_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::{
global_id::{
customer::GlobalCustomerId,
payment::GlobalPaymentId,
payment_methods::{GlobalPaymentMethodId, GlobalPaymentMethodSessionId},
refunds::GlobalRefundId,
token::GlobalTokenId,
},
id_type::{self, ApiKeyId, MerchantConnectorAccountId, ProfileAcquirerId},
lineage,
types::TimeRange,
};
/// Wrapper type that enforces masked serialization for Serde values
#[derive(Debug, Clone, Serialize)]
#[serde(transparent)]
pub struct MaskedSerdeValue {
inner: serde_json::Value,
}
impl MaskedSerdeValue {
pub fn from_masked<T: Serialize>(value: &T) -> Result<Self, serde_json::Error> {
let masked_value = hyperswitch_masking::masked_serialize(value)?;
Ok(Self {
inner: masked_value,
})
}
pub fn from_masked_optional<T: Serialize>(value: &T, context: &str) -> Option<Self> {
hyperswitch_masking::masked_serialize(value)
.map(|masked_value| Self {
inner: masked_value,
})
.inspect_err(|e| {
tracing::error!(
error_category = ?e.classify(),
context = context,
"Failed to mask serialize data"
);
})
.ok()
}
pub fn inner(&self) -> &serde_json::Value {
&self.inner
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 0,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_25_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
let masked_value = hyperswitch_masking::masked_serialize(value)?;
Ok(Self {
inner: masked_value,
})
}
pub fn from_masked_optional<T: Serialize>(value: &T, context: &str) -> Option<Self> {
hyperswitch_masking::masked_serialize(value)
.map(|masked_value| Self {
inner: masked_value,
})
.inspect_err(|e| {
tracing::error!(
error_category = ?e.classify(),
context = context,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 25,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_25_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
let masked_value = hyperswitch_masking::masked_serialize(value)?;
Ok(Self {
inner: masked_value,
})
}
pub fn from_masked_optional<T: Serialize>(value: &T, context: &str) -> Option<Self> {
hyperswitch_masking::masked_serialize(value)
.map(|masked_value| Self {
inner: masked_value,
})
.inspect_err(|e| {
tracing::error!(
error_category = ?e.classify(),
context = context,
"Failed to mask serialize data"
);
})
.ok()
}
pub fn inner(&self) -> &serde_json::Value {
&self.inner
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[serde(tag = "flow_type", rename_all = "snake_case")]
pub enum ApiEventsType {
Payout {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 25,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_25_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
let masked_value = hyperswitch_masking::masked_serialize(value)?;
Ok(Self {
inner: masked_value,
})
}
pub fn from_masked_optional<T: Serialize>(value: &T, context: &str) -> Option<Self> {
hyperswitch_masking::masked_serialize(value)
.map(|masked_value| Self {
inner: masked_value,
})
.inspect_err(|e| {
tracing::error!(
error_category = ?e.classify(),
context = context,
"Failed to mask serialize data"
);
})
.ok()
}
pub fn inner(&self) -> &serde_json::Value {
&self.inner
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[serde(tag = "flow_type", rename_all = "snake_case")]
pub enum ApiEventsType {
Payout {
payout_id: String,
},
Payment {
payment_id: GlobalPaymentId,
},
Refund {
payment_id: Option<GlobalPaymentId>,
refund_id: GlobalRefundId,
},
PaymentMethod {
payment_method_id: GlobalPaymentMethodId,
payment_method_type: Option<common_enums::PaymentMethod>,
payment_method_subtype: Option<common_enums::PaymentMethodType>,
},
PaymentMethodCreate,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 25,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_50_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[serde(tag = "flow_type", rename_all = "snake_case")]
pub enum ApiEventsType {
Payout {
payout_id: String,
},
Payment {
payment_id: GlobalPaymentId,
},
Refund {
payment_id: Option<GlobalPaymentId>,
refund_id: GlobalRefundId,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 50,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_50_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[serde(tag = "flow_type", rename_all = "snake_case")]
pub enum ApiEventsType {
Payout {
payout_id: String,
},
Payment {
payment_id: GlobalPaymentId,
},
Refund {
payment_id: Option<GlobalPaymentId>,
refund_id: GlobalRefundId,
},
PaymentMethod {
payment_method_id: GlobalPaymentMethodId,
payment_method_type: Option<common_enums::PaymentMethod>,
payment_method_subtype: Option<common_enums::PaymentMethodType>,
},
PaymentMethodCreate,
Customer {
customer_id: Option<GlobalCustomerId>,
},
BusinessProfile {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 50,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_50_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[serde(tag = "flow_type", rename_all = "snake_case")]
pub enum ApiEventsType {
Payout {
payout_id: String,
},
Payment {
payment_id: GlobalPaymentId,
},
Refund {
payment_id: Option<GlobalPaymentId>,
refund_id: GlobalRefundId,
},
PaymentMethod {
payment_method_id: GlobalPaymentMethodId,
payment_method_type: Option<common_enums::PaymentMethod>,
payment_method_subtype: Option<common_enums::PaymentMethodType>,
},
PaymentMethodCreate,
Customer {
customer_id: Option<GlobalCustomerId>,
},
BusinessProfile {
profile_id: id_type::ProfileId,
},
ApiKey {
key_id: ApiKeyId,
},
User {
user_id: String,
},
PaymentMethodList {
payment_id: Option<String>,
},
PaymentMethodListForPaymentMethods {
payment_method_id: GlobalPaymentMethodId,
},
Webhooks {
connector: MerchantConnectorAccountId,
payment_id: Option<GlobalPaymentId>,
},
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 50,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_75_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Customer {
customer_id: Option<GlobalCustomerId>,
},
BusinessProfile {
profile_id: id_type::ProfileId,
},
ApiKey {
key_id: ApiKeyId,
},
User {
user_id: String,
},
PaymentMethodList {
payment_id: Option<String>,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 75,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_75_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Customer {
customer_id: Option<GlobalCustomerId>,
},
BusinessProfile {
profile_id: id_type::ProfileId,
},
ApiKey {
key_id: ApiKeyId,
},
User {
user_id: String,
},
PaymentMethodList {
payment_id: Option<String>,
},
PaymentMethodListForPaymentMethods {
payment_method_id: GlobalPaymentMethodId,
},
Webhooks {
connector: MerchantConnectorAccountId,
payment_id: Option<GlobalPaymentId>,
},
Routing,
ResourceListAPI,
PaymentRedirectionResponse {
payment_id: GlobalPaymentId,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 75,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_75_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Customer {
customer_id: Option<GlobalCustomerId>,
},
BusinessProfile {
profile_id: id_type::ProfileId,
},
ApiKey {
key_id: ApiKeyId,
},
User {
user_id: String,
},
PaymentMethodList {
payment_id: Option<String>,
},
PaymentMethodListForPaymentMethods {
payment_method_id: GlobalPaymentMethodId,
},
Webhooks {
connector: MerchantConnectorAccountId,
payment_id: Option<GlobalPaymentId>,
},
Routing,
ResourceListAPI,
PaymentRedirectionResponse {
payment_id: GlobalPaymentId,
},
Gsm,
// TODO: This has to be removed once the corresponding apiEventTypes are created
Miscellaneous,
Keymanager,
RustLocker,
ApplePayCertificatesMigration,
FraudCheck,
Recon,
ExternalServiceAuth,
Dispute {
dispute_id: String,
},
Events {
merchant_id: id_type::MerchantId,
},
PaymentMethodCollectLink {
link_id: String,
},
Poll {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 75,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_100_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Routing,
ResourceListAPI,
PaymentRedirectionResponse {
payment_id: GlobalPaymentId,
},
Gsm,
// TODO: This has to be removed once the corresponding apiEventTypes are created
Miscellaneous,
Keymanager,
RustLocker,
ApplePayCertificatesMigration,
FraudCheck,
Recon,
ExternalServiceAuth,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 100,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_100_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Routing,
ResourceListAPI,
PaymentRedirectionResponse {
payment_id: GlobalPaymentId,
},
Gsm,
// TODO: This has to be removed once the corresponding apiEventTypes are created
Miscellaneous,
Keymanager,
RustLocker,
ApplePayCertificatesMigration,
FraudCheck,
Recon,
ExternalServiceAuth,
Dispute {
dispute_id: String,
},
Events {
merchant_id: id_type::MerchantId,
},
PaymentMethodCollectLink {
link_id: String,
},
Poll {
poll_id: String,
},
Analytics,
ClientSecret {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 100,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_100_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Routing,
ResourceListAPI,
PaymentRedirectionResponse {
payment_id: GlobalPaymentId,
},
Gsm,
// TODO: This has to be removed once the corresponding apiEventTypes are created
Miscellaneous,
Keymanager,
RustLocker,
ApplePayCertificatesMigration,
FraudCheck,
Recon,
ExternalServiceAuth,
Dispute {
dispute_id: String,
},
Events {
merchant_id: id_type::MerchantId,
},
PaymentMethodCollectLink {
link_id: String,
},
Poll {
poll_id: String,
},
Analytics,
ClientSecret {
key_id: id_type::ClientSecretId,
},
PaymentMethodSession {
payment_method_session_id: GlobalPaymentMethodSessionId,
},
Token {
token_id: Option<GlobalTokenId>,
},
ProcessTracker,
ProfileAcquirer {
profile_acquirer_id: ProfileAcquirerId,
},
ThreeDsDecisionRule,
}
pub trait ApiEventMetric {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
None
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 100,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_125_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
poll_id: String,
},
Analytics,
ClientSecret {
key_id: id_type::ClientSecretId,
},
PaymentMethodSession {
payment_method_session_id: GlobalPaymentMethodSessionId,
},
Token {
token_id: Option<GlobalTokenId>,
},
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 125,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_125_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
poll_id: String,
},
Analytics,
ClientSecret {
key_id: id_type::ClientSecretId,
},
PaymentMethodSession {
payment_method_session_id: GlobalPaymentMethodSessionId,
},
Token {
token_id: Option<GlobalTokenId>,
},
ProcessTracker,
ProfileAcquirer {
profile_acquirer_id: ProfileAcquirerId,
},
ThreeDsDecisionRule,
}
pub trait ApiEventMetric {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
None
}
}
impl ApiEventMetric for serde_json::Value {}
impl ApiEventMetric for () {}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 125,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_125_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
poll_id: String,
},
Analytics,
ClientSecret {
key_id: id_type::ClientSecretId,
},
PaymentMethodSession {
payment_method_session_id: GlobalPaymentMethodSessionId,
},
Token {
token_id: Option<GlobalTokenId>,
},
ProcessTracker,
ProfileAcquirer {
profile_acquirer_id: ProfileAcquirerId,
},
ThreeDsDecisionRule,
}
pub trait ApiEventMetric {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
None
}
}
impl ApiEventMetric for serde_json::Value {}
impl ApiEventMetric for () {}
impl ApiEventMetric for GlobalPaymentId {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.clone(),
})
}
}
impl<Q: ApiEventMetric, E> ApiEventMetric for Result<Q, E> {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
match self {
Ok(q) => q.get_api_event_type(),
Err(_) => None,
}
}
}
// TODO: Ideally all these types should be replaced by newtype responses
impl<T> ApiEventMetric for Vec<T> {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 125,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_150_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
}
}
impl ApiEventMetric for serde_json::Value {}
impl ApiEventMetric for () {}
impl ApiEventMetric for GlobalPaymentId {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.clone(),
})
}
}
impl<Q: ApiEventMetric, E> ApiEventMetric for Result<Q, E> {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 150,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_150_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
}
}
impl ApiEventMetric for serde_json::Value {}
impl ApiEventMetric for () {}
impl ApiEventMetric for GlobalPaymentId {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.clone(),
})
}
}
impl<Q: ApiEventMetric, E> ApiEventMetric for Result<Q, E> {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
match self {
Ok(q) => q.get_api_event_type(),
Err(_) => None,
}
}
}
// TODO: Ideally all these types should be replaced by newtype responses
impl<T> ApiEventMetric for Vec<T> {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Miscellaneous)
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 150,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_150_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
}
}
impl ApiEventMetric for serde_json::Value {}
impl ApiEventMetric for () {}
impl ApiEventMetric for GlobalPaymentId {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.clone(),
})
}
}
impl<Q: ApiEventMetric, E> ApiEventMetric for Result<Q, E> {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
match self {
Ok(q) => q.get_api_event_type(),
Err(_) => None,
}
}
}
// TODO: Ideally all these types should be replaced by newtype responses
impl<T> ApiEventMetric for Vec<T> {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Miscellaneous)
}
}
#[macro_export]
macro_rules! impl_api_event_type {
($event: ident, ($($type:ty),+))=> {
$(
impl ApiEventMetric for $type {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::$event)
}
}
)+
};
}
impl_api_event_type!(
Miscellaneous,
(
String,
id_type::MerchantId,
(Option<i64>, Option<i64>, String),
(Option<i64>, Option<i64>, id_type::MerchantId),
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 150,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_175_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Miscellaneous)
}
}
#[macro_export]
macro_rules! impl_api_event_type {
($event: ident, ($($type:ty),+))=> {
$(
impl ApiEventMetric for $type {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::$event)
}
}
)+
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 175,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_175_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Miscellaneous)
}
}
#[macro_export]
macro_rules! impl_api_event_type {
($event: ident, ($($type:ty),+))=> {
$(
impl ApiEventMetric for $type {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::$event)
}
}
)+
};
}
impl_api_event_type!(
Miscellaneous,
(
String,
id_type::MerchantId,
(Option<i64>, Option<i64>, String),
(Option<i64>, Option<i64>, id_type::MerchantId),
bool
)
);
impl<T: ApiEventMetric> ApiEventMetric for &T {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 175,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_175_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Miscellaneous)
}
}
#[macro_export]
macro_rules! impl_api_event_type {
($event: ident, ($($type:ty),+))=> {
$(
impl ApiEventMetric for $type {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::$event)
}
}
)+
};
}
impl_api_event_type!(
Miscellaneous,
(
String,
id_type::MerchantId,
(Option<i64>, Option<i64>, String),
(Option<i64>, Option<i64>, id_type::MerchantId),
bool
)
);
impl<T: ApiEventMetric> ApiEventMetric for &T {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
T::get_api_event_type(self)
}
}
impl ApiEventMetric for TimeRange {}
#[derive(Debug, Clone, Serialize)]
pub struct Event {
pub request_id: String,
pub timestamp: i128,
pub flow_type: FlowName,
pub connector: String,
pub url: Option<String>,
pub stage: EventStage,
pub latency_ms: Option<u64>,
pub status_code: Option<i32>,
pub request_data: Option<MaskedSerdeValue>,
pub response_data: Option<MaskedSerdeValue>,
pub headers: HashMap<String, String>,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 175,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_200_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
bool
)
);
impl<T: ApiEventMetric> ApiEventMetric for &T {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
T::get_api_event_type(self)
}
}
impl ApiEventMetric for TimeRange {}
#[derive(Debug, Clone, Serialize)]
pub struct Event {
pub request_id: String,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 200,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_200_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
bool
)
);
impl<T: ApiEventMetric> ApiEventMetric for &T {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
T::get_api_event_type(self)
}
}
impl ApiEventMetric for TimeRange {}
#[derive(Debug, Clone, Serialize)]
pub struct Event {
pub request_id: String,
pub timestamp: i128,
pub flow_type: FlowName,
pub connector: String,
pub url: Option<String>,
pub stage: EventStage,
pub latency_ms: Option<u64>,
pub status_code: Option<i32>,
pub request_data: Option<MaskedSerdeValue>,
pub response_data: Option<MaskedSerdeValue>,
pub headers: HashMap<String, String>,
#[serde(flatten)]
pub additional_fields: HashMap<String, MaskedSerdeValue>,
#[serde(flatten)]
pub lineage_ids: lineage::LineageIds<'static>,
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 200,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_200_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
bool
)
);
impl<T: ApiEventMetric> ApiEventMetric for &T {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
T::get_api_event_type(self)
}
}
impl ApiEventMetric for TimeRange {}
#[derive(Debug, Clone, Serialize)]
pub struct Event {
pub request_id: String,
pub timestamp: i128,
pub flow_type: FlowName,
pub connector: String,
pub url: Option<String>,
pub stage: EventStage,
pub latency_ms: Option<u64>,
pub status_code: Option<i32>,
pub request_data: Option<MaskedSerdeValue>,
pub response_data: Option<MaskedSerdeValue>,
pub headers: HashMap<String, String>,
#[serde(flatten)]
pub additional_fields: HashMap<String, MaskedSerdeValue>,
#[serde(flatten)]
pub lineage_ids: lineage::LineageIds<'static>,
}
impl Event {
pub fn add_reference_id(&mut self, reference_id: Option<&str>) {
reference_id
.and_then(|ref_id| {
MaskedSerdeValue::from_masked_optional(&ref_id.to_string(), "reference_id")
})
.map(|masked_ref| {
self.additional_fields
.insert("reference_id".to_string(), masked_ref);
});
}
pub fn set_grpc_error_response(&mut self, tonic_error: &tonic::Status) {
self.status_code = Some(tonic_error.code().into());
let error_body = serde_json::json!({
"grpc_code": i32::from(tonic_error.code()),
"grpc_code_name": format!("{:?}", tonic_error.code())
});
self.response_data =
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 200,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_225_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
#[serde(flatten)]
pub additional_fields: HashMap<String, MaskedSerdeValue>,
#[serde(flatten)]
pub lineage_ids: lineage::LineageIds<'static>,
}
impl Event {
pub fn add_reference_id(&mut self, reference_id: Option<&str>) {
reference_id
.and_then(|ref_id| {
MaskedSerdeValue::from_masked_optional(&ref_id.to_string(), "reference_id")
})
.map(|masked_ref| {
self.additional_fields
.insert("reference_id".to_string(), masked_ref);
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 225,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_225_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
#[serde(flatten)]
pub additional_fields: HashMap<String, MaskedSerdeValue>,
#[serde(flatten)]
pub lineage_ids: lineage::LineageIds<'static>,
}
impl Event {
pub fn add_reference_id(&mut self, reference_id: Option<&str>) {
reference_id
.and_then(|ref_id| {
MaskedSerdeValue::from_masked_optional(&ref_id.to_string(), "reference_id")
})
.map(|masked_ref| {
self.additional_fields
.insert("reference_id".to_string(), masked_ref);
});
}
pub fn set_grpc_error_response(&mut self, tonic_error: &tonic::Status) {
self.status_code = Some(tonic_error.code().into());
let error_body = serde_json::json!({
"grpc_code": i32::from(tonic_error.code()),
"grpc_code_name": format!("{:?}", tonic_error.code())
});
self.response_data =
MaskedSerdeValue::from_masked_optional(&error_body, "grpc_error_response");
}
pub fn set_grpc_success_response<R: Serialize>(&mut self, response: &R) {
self.status_code = Some(0);
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 225,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_225_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
#[serde(flatten)]
pub additional_fields: HashMap<String, MaskedSerdeValue>,
#[serde(flatten)]
pub lineage_ids: lineage::LineageIds<'static>,
}
impl Event {
pub fn add_reference_id(&mut self, reference_id: Option<&str>) {
reference_id
.and_then(|ref_id| {
MaskedSerdeValue::from_masked_optional(&ref_id.to_string(), "reference_id")
})
.map(|masked_ref| {
self.additional_fields
.insert("reference_id".to_string(), masked_ref);
});
}
pub fn set_grpc_error_response(&mut self, tonic_error: &tonic::Status) {
self.status_code = Some(tonic_error.code().into());
let error_body = serde_json::json!({
"grpc_code": i32::from(tonic_error.code()),
"grpc_code_name": format!("{:?}", tonic_error.code())
});
self.response_data =
MaskedSerdeValue::from_masked_optional(&error_body, "grpc_error_response");
}
pub fn set_grpc_success_response<R: Serialize>(&mut self, response: &R) {
self.status_code = Some(0);
self.response_data =
MaskedSerdeValue::from_masked_optional(response, "grpc_success_response");
}
pub fn set_connector_response<R: Serialize>(&mut self, response: &R) {
self.response_data = MaskedSerdeValue::from_masked_optional(response, "connector_response");
}
}
#[derive(strum::Display)]
#[strum(serialize_all = "snake_case")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum FlowName {
Authorize,
Refund,
Capture,
Void,
VoidPostCapture,
Psync,
Rsync,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 225,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_250_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
MaskedSerdeValue::from_masked_optional(&error_body, "grpc_error_response");
}
pub fn set_grpc_success_response<R: Serialize>(&mut self, response: &R) {
self.status_code = Some(0);
self.response_data =
MaskedSerdeValue::from_masked_optional(response, "grpc_success_response");
}
pub fn set_connector_response<R: Serialize>(&mut self, response: &R) {
self.response_data = MaskedSerdeValue::from_masked_optional(response, "connector_response");
}
}
#[derive(strum::Display)]
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 250,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_250_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
MaskedSerdeValue::from_masked_optional(&error_body, "grpc_error_response");
}
pub fn set_grpc_success_response<R: Serialize>(&mut self, response: &R) {
self.status_code = Some(0);
self.response_data =
MaskedSerdeValue::from_masked_optional(response, "grpc_success_response");
}
pub fn set_connector_response<R: Serialize>(&mut self, response: &R) {
self.response_data = MaskedSerdeValue::from_masked_optional(response, "connector_response");
}
}
#[derive(strum::Display)]
#[strum(serialize_all = "snake_case")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum FlowName {
Authorize,
Refund,
Capture,
Void,
VoidPostCapture,
Psync,
Rsync,
AcceptDispute,
SubmitEvidence,
DefendDispute,
Dsync,
IncomingWebhook,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 250,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_250_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
MaskedSerdeValue::from_masked_optional(&error_body, "grpc_error_response");
}
pub fn set_grpc_success_response<R: Serialize>(&mut self, response: &R) {
self.status_code = Some(0);
self.response_data =
MaskedSerdeValue::from_masked_optional(response, "grpc_success_response");
}
pub fn set_connector_response<R: Serialize>(&mut self, response: &R) {
self.response_data = MaskedSerdeValue::from_masked_optional(response, "connector_response");
}
}
#[derive(strum::Display)]
#[strum(serialize_all = "snake_case")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum FlowName {
Authorize,
Refund,
Capture,
Void,
VoidPostCapture,
Psync,
Rsync,
AcceptDispute,
SubmitEvidence,
DefendDispute,
Dsync,
IncomingWebhook,
SetupMandate,
RepeatPayment,
CreateOrder,
CreateSessionToken,
CreateAccessToken,
CreateConnectorCustomer,
PaymentMethodToken,
PreAuthenticate,
Authenticate,
PostAuthenticate,
Unknown,
}
impl FlowName {
pub fn as_str(&self) -> &'static str {
match self {
Self::Authorize => "Authorize",
Self::Refund => "Refund",
Self::Capture => "Capture",
Self::Void => "Void",
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 250,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_275_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
AcceptDispute,
SubmitEvidence,
DefendDispute,
Dsync,
IncomingWebhook,
SetupMandate,
RepeatPayment,
CreateOrder,
CreateSessionToken,
CreateAccessToken,
CreateConnectorCustomer,
PaymentMethodToken,
PreAuthenticate,
Authenticate,
PostAuthenticate,
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 275,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_275_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
AcceptDispute,
SubmitEvidence,
DefendDispute,
Dsync,
IncomingWebhook,
SetupMandate,
RepeatPayment,
CreateOrder,
CreateSessionToken,
CreateAccessToken,
CreateConnectorCustomer,
PaymentMethodToken,
PreAuthenticate,
Authenticate,
PostAuthenticate,
Unknown,
}
impl FlowName {
pub fn as_str(&self) -> &'static str {
match self {
Self::Authorize => "Authorize",
Self::Refund => "Refund",
Self::Capture => "Capture",
Self::Void => "Void",
Self::VoidPostCapture => "VoidPostCapture",
Self::Psync => "Psync",
Self::Rsync => "Rsync",
Self::AcceptDispute => "AcceptDispute",
Self::SubmitEvidence => "SubmitEvidence",
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 275,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_275_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
AcceptDispute,
SubmitEvidence,
DefendDispute,
Dsync,
IncomingWebhook,
SetupMandate,
RepeatPayment,
CreateOrder,
CreateSessionToken,
CreateAccessToken,
CreateConnectorCustomer,
PaymentMethodToken,
PreAuthenticate,
Authenticate,
PostAuthenticate,
Unknown,
}
impl FlowName {
pub fn as_str(&self) -> &'static str {
match self {
Self::Authorize => "Authorize",
Self::Refund => "Refund",
Self::Capture => "Capture",
Self::Void => "Void",
Self::VoidPostCapture => "VoidPostCapture",
Self::Psync => "Psync",
Self::Rsync => "Rsync",
Self::AcceptDispute => "AcceptDispute",
Self::SubmitEvidence => "SubmitEvidence",
Self::DefendDispute => "DefendDispute",
Self::Dsync => "Dsync",
Self::IncomingWebhook => "IncomingWebhook",
Self::SetupMandate => "SetupMandate",
Self::RepeatPayment => "RepeatPayment",
Self::CreateOrder => "CreateOrder",
Self::PaymentMethodToken => "PaymentMethodToken",
Self::CreateSessionToken => "CreateSessionToken",
Self::CreateAccessToken => "CreateAccessToken",
Self::CreateConnectorCustomer => "CreateConnectorCustomer",
Self::PreAuthenticate => "PreAuthenticate",
Self::Authenticate => "Authenticate",
Self::PostAuthenticate => "PostAuthenticate",
Self::Unknown => "Unknown",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EventStage {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 275,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_300_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Self::VoidPostCapture => "VoidPostCapture",
Self::Psync => "Psync",
Self::Rsync => "Rsync",
Self::AcceptDispute => "AcceptDispute",
Self::SubmitEvidence => "SubmitEvidence",
Self::DefendDispute => "DefendDispute",
Self::Dsync => "Dsync",
Self::IncomingWebhook => "IncomingWebhook",
Self::SetupMandate => "SetupMandate",
Self::RepeatPayment => "RepeatPayment",
Self::CreateOrder => "CreateOrder",
Self::PaymentMethodToken => "PaymentMethodToken",
Self::CreateSessionToken => "CreateSessionToken",
Self::CreateAccessToken => "CreateAccessToken",
Self::CreateConnectorCustomer => "CreateConnectorCustomer",
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 300,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_300_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Self::VoidPostCapture => "VoidPostCapture",
Self::Psync => "Psync",
Self::Rsync => "Rsync",
Self::AcceptDispute => "AcceptDispute",
Self::SubmitEvidence => "SubmitEvidence",
Self::DefendDispute => "DefendDispute",
Self::Dsync => "Dsync",
Self::IncomingWebhook => "IncomingWebhook",
Self::SetupMandate => "SetupMandate",
Self::RepeatPayment => "RepeatPayment",
Self::CreateOrder => "CreateOrder",
Self::PaymentMethodToken => "PaymentMethodToken",
Self::CreateSessionToken => "CreateSessionToken",
Self::CreateAccessToken => "CreateAccessToken",
Self::CreateConnectorCustomer => "CreateConnectorCustomer",
Self::PreAuthenticate => "PreAuthenticate",
Self::Authenticate => "Authenticate",
Self::PostAuthenticate => "PostAuthenticate",
Self::Unknown => "Unknown",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EventStage {
ConnectorCall,
GrpcRequest,
}
impl EventStage {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 300,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_300_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
Self::VoidPostCapture => "VoidPostCapture",
Self::Psync => "Psync",
Self::Rsync => "Rsync",
Self::AcceptDispute => "AcceptDispute",
Self::SubmitEvidence => "SubmitEvidence",
Self::DefendDispute => "DefendDispute",
Self::Dsync => "Dsync",
Self::IncomingWebhook => "IncomingWebhook",
Self::SetupMandate => "SetupMandate",
Self::RepeatPayment => "RepeatPayment",
Self::CreateOrder => "CreateOrder",
Self::PaymentMethodToken => "PaymentMethodToken",
Self::CreateSessionToken => "CreateSessionToken",
Self::CreateAccessToken => "CreateAccessToken",
Self::CreateConnectorCustomer => "CreateConnectorCustomer",
Self::PreAuthenticate => "PreAuthenticate",
Self::Authenticate => "Authenticate",
Self::PostAuthenticate => "PostAuthenticate",
Self::Unknown => "Unknown",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum EventStage {
ConnectorCall,
GrpcRequest,
}
impl EventStage {
pub fn as_str(&self) -> &'static str {
match self {
Self::ConnectorCall => "CONNECTOR_CALL",
Self::GrpcRequest => "GRPC_REQUEST",
}
}
}
/// Configuration for events system
#[derive(Debug, Clone, Deserialize)]
pub struct EventConfig {
pub enabled: bool,
pub topic: String,
pub brokers: Vec<String>,
pub partition_key_field: String,
#[serde(default)]
pub transformations: HashMap<String, String>, // target_path β source_field
#[serde(default)]
pub static_values: HashMap<String, String>, // target_path β static_value
#[serde(default)]
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 300,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_325_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
ConnectorCall,
GrpcRequest,
}
impl EventStage {
pub fn as_str(&self) -> &'static str {
match self {
Self::ConnectorCall => "CONNECTOR_CALL",
Self::GrpcRequest => "GRPC_REQUEST",
}
}
}
/// Configuration for events system
#[derive(Debug, Clone, Deserialize)]
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 325,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_325_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
ConnectorCall,
GrpcRequest,
}
impl EventStage {
pub fn as_str(&self) -> &'static str {
match self {
Self::ConnectorCall => "CONNECTOR_CALL",
Self::GrpcRequest => "GRPC_REQUEST",
}
}
}
/// Configuration for events system
#[derive(Debug, Clone, Deserialize)]
pub struct EventConfig {
pub enabled: bool,
pub topic: String,
pub brokers: Vec<String>,
pub partition_key_field: String,
#[serde(default)]
pub transformations: HashMap<String, String>, // target_path β source_field
#[serde(default)]
pub static_values: HashMap<String, String>, // target_path β static_value
#[serde(default)]
pub extractions: HashMap<String, String>, // target_path β extraction_path
}
impl Default for EventConfig {
fn default() -> Self {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 325,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_325_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
ConnectorCall,
GrpcRequest,
}
impl EventStage {
pub fn as_str(&self) -> &'static str {
match self {
Self::ConnectorCall => "CONNECTOR_CALL",
Self::GrpcRequest => "GRPC_REQUEST",
}
}
}
/// Configuration for events system
#[derive(Debug, Clone, Deserialize)]
pub struct EventConfig {
pub enabled: bool,
pub topic: String,
pub brokers: Vec<String>,
pub partition_key_field: String,
#[serde(default)]
pub transformations: HashMap<String, String>, // target_path β source_field
#[serde(default)]
pub static_values: HashMap<String, String>, // target_path β static_value
#[serde(default)]
pub extractions: HashMap<String, String>, // target_path β extraction_path
}
impl Default for EventConfig {
fn default() -> Self {
Self {
enabled: false,
topic: "events".to_string(),
brokers: vec!["localhost:9092".to_string()],
partition_key_field: "request_id".to_string(),
transformations: HashMap::new(),
static_values: HashMap::new(),
extractions: HashMap::new(),
}
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 41,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 325,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_350_15 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
pub extractions: HashMap<String, String>, // target_path β extraction_path
}
impl Default for EventConfig {
fn default() -> Self {
Self {
enabled: false,
topic: "events".to_string(),
brokers: vec!["localhost:9092".to_string()],
partition_key_field: "request_id".to_string(),
transformations: HashMap::new(),
static_values: HashMap::new(),
extractions: HashMap::new(),
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 350,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_350_30 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
pub extractions: HashMap<String, String>, // target_path β extraction_path
}
impl Default for EventConfig {
fn default() -> Self {
Self {
enabled: false,
topic: "events".to_string(),
brokers: vec!["localhost:9092".to_string()],
partition_key_field: "request_id".to_string(),
transformations: HashMap::new(),
static_values: HashMap::new(),
extractions: HashMap::new(),
}
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 16,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 350,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-4813005579221307816_350_50 | clm | snippet | // connector-service/backend/common_utils/src/events.rs
pub extractions: HashMap<String, String>, // target_path β extraction_path
}
impl Default for EventConfig {
fn default() -> Self {
Self {
enabled: false,
topic: "events".to_string(),
brokers: vec!["localhost:9092".to_string()],
partition_key_field: "request_id".to_string(),
transformations: HashMap::new(),
static_values: HashMap::new(),
extractions: HashMap::new(),
}
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 16,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 350,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_0_15 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
use std::collections::HashSet;
use bytes::Bytes;
use hyperswitch_masking::{Maskable, Secret};
/// Configuration for header masking in gRPC metadata.
#[derive(Debug, Clone)]
pub struct HeaderMaskingConfig {
unmasked_keys: HashSet<String>,
}
impl HeaderMaskingConfig {
pub fn new(unmasked_keys: HashSet<String>) -> Self {
Self { unmasked_keys }
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 0,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_0_30 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
use std::collections::HashSet;
use bytes::Bytes;
use hyperswitch_masking::{Maskable, Secret};
/// Configuration for header masking in gRPC metadata.
#[derive(Debug, Clone)]
pub struct HeaderMaskingConfig {
unmasked_keys: HashSet<String>,
}
impl HeaderMaskingConfig {
pub fn new(unmasked_keys: HashSet<String>) -> Self {
Self { unmasked_keys }
}
pub fn should_unmask(&self, key: &str) -> bool {
self.unmasked_keys.contains(&key.to_lowercase())
}
}
impl<'de> serde::Deserialize<'de> for HeaderMaskingConfig {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
#[derive(serde::Deserialize)]
struct Config {
keys: Vec<String>,
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 0,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_0_50 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
use std::collections::HashSet;
use bytes::Bytes;
use hyperswitch_masking::{Maskable, Secret};
/// Configuration for header masking in gRPC metadata.
#[derive(Debug, Clone)]
pub struct HeaderMaskingConfig {
unmasked_keys: HashSet<String>,
}
impl HeaderMaskingConfig {
pub fn new(unmasked_keys: HashSet<String>) -> Self {
Self { unmasked_keys }
}
pub fn should_unmask(&self, key: &str) -> bool {
self.unmasked_keys.contains(&key.to_lowercase())
}
}
impl<'de> serde::Deserialize<'de> for HeaderMaskingConfig {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
#[derive(serde::Deserialize)]
struct Config {
keys: Vec<String>,
}
Config::deserialize(deserializer).map(|config| Self {
unmasked_keys: config
.keys
.into_iter()
.map(|key| key.to_lowercase())
.collect(),
})
}
}
impl Default for HeaderMaskingConfig {
fn default() -> Self {
Self {
unmasked_keys: ["content-type", "content-length", "user-agent"]
.iter()
.map(|&key| key.to_string())
.collect(),
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 0,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_25_15 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
{
#[derive(serde::Deserialize)]
struct Config {
keys: Vec<String>,
}
Config::deserialize(deserializer).map(|config| Self {
unmasked_keys: config
.keys
.into_iter()
.map(|key| key.to_lowercase())
.collect(),
})
}
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 25,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_25_30 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
{
#[derive(serde::Deserialize)]
struct Config {
keys: Vec<String>,
}
Config::deserialize(deserializer).map(|config| Self {
unmasked_keys: config
.keys
.into_iter()
.map(|key| key.to_lowercase())
.collect(),
})
}
}
impl Default for HeaderMaskingConfig {
fn default() -> Self {
Self {
unmasked_keys: ["content-type", "content-length", "user-agent"]
.iter()
.map(|&key| key.to_string())
.collect(),
}
}
}
/// Secure wrapper for gRPC metadata with configurable masking.
/// ASCII headers:
/// - get(key) -> Secret<String> - Forces explicit .expose() call
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 25,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_25_50 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
{
#[derive(serde::Deserialize)]
struct Config {
keys: Vec<String>,
}
Config::deserialize(deserializer).map(|config| Self {
unmasked_keys: config
.keys
.into_iter()
.map(|key| key.to_lowercase())
.collect(),
})
}
}
impl Default for HeaderMaskingConfig {
fn default() -> Self {
Self {
unmasked_keys: ["content-type", "content-length", "user-agent"]
.iter()
.map(|&key| key.to_string())
.collect(),
}
}
}
/// Secure wrapper for gRPC metadata with configurable masking.
/// ASCII headers:
/// - get(key) -> Secret<String> - Forces explicit .expose() call
/// - get_raw(key) -> String - Raw access
/// - get_maskable(key) -> Maskable<String> - For logging/observability
///
/// Binary headers:
/// - get_bin(key) -> Secret<Bytes> - Forces explicit .expose() call
/// - get_bin_raw(key) -> Bytes - Raw access
/// - get_bin_maskable(key) -> Maskable<String> - Base64 encoded for logging
/// - get_all_masked() -> HashMap<String, String> - Safe for logging
#[derive(Clone)]
pub struct MaskedMetadata {
raw_metadata: tonic::metadata::MetadataMap,
masking_config: HeaderMaskingConfig,
}
impl std::fmt::Debug for MaskedMetadata {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MaskedMetadata")
.field("masked_headers", &self.get_all_masked())
.field("masking_config", &self.masking_config)
.finish()
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 25,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_50_15 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
}
/// Secure wrapper for gRPC metadata with configurable masking.
/// ASCII headers:
/// - get(key) -> Secret<String> - Forces explicit .expose() call
/// - get_raw(key) -> String - Raw access
/// - get_maskable(key) -> Maskable<String> - For logging/observability
///
/// Binary headers:
/// - get_bin(key) -> Secret<Bytes> - Forces explicit .expose() call
/// - get_bin_raw(key) -> Bytes - Raw access
/// - get_bin_maskable(key) -> Maskable<String> - Base64 encoded for logging
/// - get_all_masked() -> HashMap<String, String> - Safe for logging
#[derive(Clone)]
pub struct MaskedMetadata {
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 50,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_50_30 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
}
/// Secure wrapper for gRPC metadata with configurable masking.
/// ASCII headers:
/// - get(key) -> Secret<String> - Forces explicit .expose() call
/// - get_raw(key) -> String - Raw access
/// - get_maskable(key) -> Maskable<String> - For logging/observability
///
/// Binary headers:
/// - get_bin(key) -> Secret<Bytes> - Forces explicit .expose() call
/// - get_bin_raw(key) -> Bytes - Raw access
/// - get_bin_maskable(key) -> Maskable<String> - Base64 encoded for logging
/// - get_all_masked() -> HashMap<String, String> - Safe for logging
#[derive(Clone)]
pub struct MaskedMetadata {
raw_metadata: tonic::metadata::MetadataMap,
masking_config: HeaderMaskingConfig,
}
impl std::fmt::Debug for MaskedMetadata {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MaskedMetadata")
.field("masked_headers", &self.get_all_masked())
.field("masking_config", &self.masking_config)
.finish()
}
}
impl MaskedMetadata {
pub fn new(
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 50,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_50_50 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
}
/// Secure wrapper for gRPC metadata with configurable masking.
/// ASCII headers:
/// - get(key) -> Secret<String> - Forces explicit .expose() call
/// - get_raw(key) -> String - Raw access
/// - get_maskable(key) -> Maskable<String> - For logging/observability
///
/// Binary headers:
/// - get_bin(key) -> Secret<Bytes> - Forces explicit .expose() call
/// - get_bin_raw(key) -> Bytes - Raw access
/// - get_bin_maskable(key) -> Maskable<String> - Base64 encoded for logging
/// - get_all_masked() -> HashMap<String, String> - Safe for logging
#[derive(Clone)]
pub struct MaskedMetadata {
raw_metadata: tonic::metadata::MetadataMap,
masking_config: HeaderMaskingConfig,
}
impl std::fmt::Debug for MaskedMetadata {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MaskedMetadata")
.field("masked_headers", &self.get_all_masked())
.field("masking_config", &self.masking_config)
.finish()
}
}
impl MaskedMetadata {
pub fn new(
raw_metadata: tonic::metadata::MetadataMap,
masking_config: HeaderMaskingConfig,
) -> Self {
Self {
raw_metadata,
masking_config,
}
}
/// Always returns Secret - business logic must call .expose() explicitly
pub fn get(&self, key: &str) -> Option<Secret<String>> {
self.raw_metadata
.get(key)
.and_then(|value| value.to_str().ok())
.map(|s| Secret::new(s.to_string()))
}
/// Returns raw string value regardless of config
pub fn get_raw(&self, key: &str) -> Option<String> {
self.raw_metadata
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 50,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 50,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_75_15 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
}
}
impl MaskedMetadata {
pub fn new(
raw_metadata: tonic::metadata::MetadataMap,
masking_config: HeaderMaskingConfig,
) -> Self {
Self {
raw_metadata,
masking_config,
}
}
/// Always returns Secret - business logic must call .expose() explicitly
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 15,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 75,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
connector-service_snippet_-1874607272906183358_75_30 | clm | snippet | // connector-service/backend/common_utils/src/metadata.rs
}
}
impl MaskedMetadata {
pub fn new(
raw_metadata: tonic::metadata::MetadataMap,
masking_config: HeaderMaskingConfig,
) -> Self {
Self {
raw_metadata,
masking_config,
}
}
/// Always returns Secret - business logic must call .expose() explicitly
pub fn get(&self, key: &str) -> Option<Secret<String>> {
self.raw_metadata
.get(key)
.and_then(|value| value.to_str().ok())
.map(|s| Secret::new(s.to_string()))
}
/// Returns raw string value regardless of config
pub fn get_raw(&self, key: &str) -> Option<String> {
self.raw_metadata
.get(key)
.and_then(|value| value.to_str().ok())
.map(|s| s.to_string())
}
| {
"chunk": null,
"crate": "ucs_common_utils",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": null,
"is_async": null,
"is_pub": null,
"lines": 30,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "connector-service",
"start_line": 75,
"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.