id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_snippet_2179811235784210369_75_15
clm
snippet
// connector-service/backend/common_utils/src/errors.rs pub enum PercentageError { /// Percentage Value provided was invalid #[error("Invalid Percentage value")] InvalidPercentageValue, /// Error occurred while calculating percentage #[error("Failed apply percentage of {percentage} on {amount}")] UnableToApplyPercentage { /// percentage value percentage: f32, /// amount value amount: MinorUnit, }, }
{ "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_2179811235784210369_75_30
clm
snippet
// connector-service/backend/common_utils/src/errors.rs pub enum PercentageError { /// Percentage Value provided was invalid #[error("Invalid Percentage value")] InvalidPercentageValue, /// Error occurred while calculating percentage #[error("Failed apply percentage of {percentage} on {amount}")] UnableToApplyPercentage { /// percentage value percentage: f32, /// amount value amount: MinorUnit, }, } /// Allow [error_stack::Report] to convert between error types pub trait ErrorSwitch<T> { /// Get the next error type that the source error can be escalated into /// This does not consume the source error since we need to keep it in context fn switch(&self) -> T; } /// Allow [error_stack::Report] to convert between error types /// This serves as an alternative to [ErrorSwitch] pub trait ErrorSwitchFrom<T> { /// Convert to an error type that the source can be escalated into /// This does not consume the source error since we need to keep it in context fn switch_from(error: &T) -> 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": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2179811235784210369_75_50
clm
snippet
// connector-service/backend/common_utils/src/errors.rs pub enum PercentageError { /// Percentage Value provided was invalid #[error("Invalid Percentage value")] InvalidPercentageValue, /// Error occurred while calculating percentage #[error("Failed apply percentage of {percentage} on {amount}")] UnableToApplyPercentage { /// percentage value percentage: f32, /// amount value amount: MinorUnit, }, } /// Allow [error_stack::Report] to convert between error types pub trait ErrorSwitch<T> { /// Get the next error type that the source error can be escalated into /// This does not consume the source error since we need to keep it in context fn switch(&self) -> T; } /// Allow [error_stack::Report] to convert between error types /// This serves as an alternative to [ErrorSwitch] pub trait ErrorSwitchFrom<T> { /// Convert to an error type that the source can be escalated into /// This does not consume the source error since we need to keep it in context fn switch_from(error: &T) -> Self; } impl<T, S> ErrorSwitch<T> for S where T: ErrorSwitchFrom<Self>, { fn switch(&self) -> T { T::switch_from(self) } } /// Allows [error_stack::Report] to change between error contexts /// using the dependent [ErrorSwitch] trait to define relations & mappings between traits pub trait ReportSwitchExt<T, U> { /// Switch to the intended report by calling switch /// requires error switch to be already implemented on the error type fn switch(self) -> Result<T, error_stack::Report<U>>; } impl<T, U, V> ReportSwitchExt<T, U> for Result<T, error_stack::Report<V>> where V: ErrorSwitch<U> + error_stack::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": 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_2179811235784210369_100_15
clm
snippet
// connector-service/backend/common_utils/src/errors.rs /// Convert to an error type that the source can be escalated into /// This does not consume the source error since we need to keep it in context fn switch_from(error: &T) -> Self; } impl<T, S> ErrorSwitch<T> for S where T: ErrorSwitchFrom<Self>, { fn switch(&self) -> T { T::switch_from(self) } } /// Allows [error_stack::Report] to change between error contexts
{ "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_2179811235784210369_100_30
clm
snippet
// connector-service/backend/common_utils/src/errors.rs /// Convert to an error type that the source can be escalated into /// This does not consume the source error since we need to keep it in context fn switch_from(error: &T) -> Self; } impl<T, S> ErrorSwitch<T> for S where T: ErrorSwitchFrom<Self>, { fn switch(&self) -> T { T::switch_from(self) } } /// Allows [error_stack::Report] to change between error contexts /// using the dependent [ErrorSwitch] trait to define relations & mappings between traits pub trait ReportSwitchExt<T, U> { /// Switch to the intended report by calling switch /// requires error switch to be already implemented on the error type fn switch(self) -> Result<T, error_stack::Report<U>>; } impl<T, U, V> ReportSwitchExt<T, U> for Result<T, error_stack::Report<V>> where V: ErrorSwitch<U> + error_stack::Context, U: error_stack::Context, { #[track_caller] fn switch(self) -> Result<T, error_stack::Report<U>> { match 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": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2179811235784210369_100_50
clm
snippet
// connector-service/backend/common_utils/src/errors.rs /// Convert to an error type that the source can be escalated into /// This does not consume the source error since we need to keep it in context fn switch_from(error: &T) -> Self; } impl<T, S> ErrorSwitch<T> for S where T: ErrorSwitchFrom<Self>, { fn switch(&self) -> T { T::switch_from(self) } } /// Allows [error_stack::Report] to change between error contexts /// using the dependent [ErrorSwitch] trait to define relations & mappings between traits pub trait ReportSwitchExt<T, U> { /// Switch to the intended report by calling switch /// requires error switch to be already implemented on the error type fn switch(self) -> Result<T, error_stack::Report<U>>; } impl<T, U, V> ReportSwitchExt<T, U> for Result<T, error_stack::Report<V>> where V: ErrorSwitch<U> + error_stack::Context, U: error_stack::Context, { #[track_caller] fn switch(self) -> Result<T, error_stack::Report<U>> { match self { Ok(i) => Ok(i), Err(er) => { let new_c = er.current_context().switch(); Err(er.change_context(new_c)) } } } } #[derive(Debug, thiserror::Error)] pub enum CryptoError { /// The cryptographic algorithm was unable to encode the message #[error("Failed to encode given message")] EncodingFailed, /// The cryptographic algorithm was unable to decode the message #[error("Failed to decode given message")] DecodingFailed, /// The cryptographic algorithm was unable to sign the message #[error("Failed to sign message")] MessageSigningFailed,
{ "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_2179811235784210369_125_15
clm
snippet
// connector-service/backend/common_utils/src/errors.rs U: error_stack::Context, { #[track_caller] fn switch(self) -> Result<T, error_stack::Report<U>> { match self { Ok(i) => Ok(i), Err(er) => { let new_c = er.current_context().switch(); Err(er.change_context(new_c)) } } } } #[derive(Debug, thiserror::Error)]
{ "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_2179811235784210369_125_30
clm
snippet
// connector-service/backend/common_utils/src/errors.rs U: error_stack::Context, { #[track_caller] fn switch(self) -> Result<T, error_stack::Report<U>> { match self { Ok(i) => Ok(i), Err(er) => { let new_c = er.current_context().switch(); Err(er.change_context(new_c)) } } } } #[derive(Debug, thiserror::Error)] pub enum CryptoError { /// The cryptographic algorithm was unable to encode the message #[error("Failed to encode given message")] EncodingFailed, /// The cryptographic algorithm was unable to decode the message #[error("Failed to decode given message")] DecodingFailed, /// The cryptographic algorithm was unable to sign the message #[error("Failed to sign message")] MessageSigningFailed, /// The cryptographic algorithm was unable to verify the given signature #[error("Failed to verify signature")] SignatureVerificationFailed, /// The provided key length is invalid for the cryptographic algorithm #[error("Invalid key length")]
{ "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_2179811235784210369_125_50
clm
snippet
// connector-service/backend/common_utils/src/errors.rs U: error_stack::Context, { #[track_caller] fn switch(self) -> Result<T, error_stack::Report<U>> { match self { Ok(i) => Ok(i), Err(er) => { let new_c = er.current_context().switch(); Err(er.change_context(new_c)) } } } } #[derive(Debug, thiserror::Error)] pub enum CryptoError { /// The cryptographic algorithm was unable to encode the message #[error("Failed to encode given message")] EncodingFailed, /// The cryptographic algorithm was unable to decode the message #[error("Failed to decode given message")] DecodingFailed, /// The cryptographic algorithm was unable to sign the message #[error("Failed to sign message")] MessageSigningFailed, /// The cryptographic algorithm was unable to verify the given signature #[error("Failed to verify signature")] SignatureVerificationFailed, /// The provided key length is invalid for the cryptographic algorithm #[error("Invalid key length")] InvalidKeyLength, /// The provided IV length is invalid for the cryptographic algorithm #[error("Invalid IV length")] InvalidIvLength, } impl ErrorSwitchFrom<common_enums::CurrencyError> for ParsingError { fn switch_from(error: &common_enums::CurrencyError) -> Self { match error { common_enums::CurrencyError::UnsupportedCurrency { .. } => { Self::StructParseFailure("currency decimal configuration") } } } } /// Integrity check errors. #[derive(Debug, Clone, PartialEq, Default)] pub struct IntegrityCheckError { /// Field names for which integrity check failed!
{ "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_2179811235784210369_150_15
clm
snippet
// connector-service/backend/common_utils/src/errors.rs /// The cryptographic algorithm was unable to verify the given signature #[error("Failed to verify signature")] SignatureVerificationFailed, /// The provided key length is invalid for the cryptographic algorithm #[error("Invalid key length")] InvalidKeyLength, /// The provided IV length is invalid for the cryptographic algorithm #[error("Invalid IV length")] InvalidIvLength, } impl ErrorSwitchFrom<common_enums::CurrencyError> for ParsingError { fn switch_from(error: &common_enums::CurrencyError) -> Self { match error { common_enums::CurrencyError::UnsupportedCurrency { .. } => {
{ "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_2179811235784210369_150_30
clm
snippet
// connector-service/backend/common_utils/src/errors.rs /// The cryptographic algorithm was unable to verify the given signature #[error("Failed to verify signature")] SignatureVerificationFailed, /// The provided key length is invalid for the cryptographic algorithm #[error("Invalid key length")] InvalidKeyLength, /// The provided IV length is invalid for the cryptographic algorithm #[error("Invalid IV length")] InvalidIvLength, } impl ErrorSwitchFrom<common_enums::CurrencyError> for ParsingError { fn switch_from(error: &common_enums::CurrencyError) -> Self { match error { common_enums::CurrencyError::UnsupportedCurrency { .. } => { Self::StructParseFailure("currency decimal configuration") } } } } /// Integrity check errors. #[derive(Debug, Clone, PartialEq, Default)] pub struct IntegrityCheckError { /// Field names for which integrity check failed! pub field_names: String, /// Connector transaction reference id pub connector_transaction_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": 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_2179811235784210369_150_50
clm
snippet
// connector-service/backend/common_utils/src/errors.rs /// The cryptographic algorithm was unable to verify the given signature #[error("Failed to verify signature")] SignatureVerificationFailed, /// The provided key length is invalid for the cryptographic algorithm #[error("Invalid key length")] InvalidKeyLength, /// The provided IV length is invalid for the cryptographic algorithm #[error("Invalid IV length")] InvalidIvLength, } impl ErrorSwitchFrom<common_enums::CurrencyError> for ParsingError { fn switch_from(error: &common_enums::CurrencyError) -> Self { match error { common_enums::CurrencyError::UnsupportedCurrency { .. } => { Self::StructParseFailure("currency decimal configuration") } } } } /// Integrity check errors. #[derive(Debug, Clone, PartialEq, Default)] pub struct IntegrityCheckError { /// Field names for which integrity check failed! pub field_names: String, /// Connector transaction reference id pub connector_transaction_id: Option<String>, } /// Event publisher errors. #[derive(Debug, thiserror::Error)] pub enum EventPublisherError { /// Failed to initialize Kafka writer #[error("Failed to initialize Kafka writer")] KafkaWriterInitializationFailed, /// Failed to serialize event data #[error("Failed to serialize event data")] EventSerializationFailed, /// Failed to publish event to Kafka #[error("Failed to publish event to Kafka")] EventPublishFailed, /// Invalid configuration provided #[error("Invalid configuration: {message}")] InvalidConfiguration { message: String }, /// Event publisher already initialized #[error("Event publisher already initialized")] AlreadyInitialized, /// Failed to process event transformations #[error("Failed to process event transformations")]
{ "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_2179811235784210369_175_15
clm
snippet
// connector-service/backend/common_utils/src/errors.rs pub field_names: String, /// Connector transaction reference id pub connector_transaction_id: Option<String>, } /// Event publisher errors. #[derive(Debug, thiserror::Error)] pub enum EventPublisherError { /// Failed to initialize Kafka writer #[error("Failed to initialize Kafka writer")] KafkaWriterInitializationFailed, /// Failed to serialize event data #[error("Failed to serialize event data")] EventSerializationFailed, /// Failed to publish event to Kafka
{ "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_2179811235784210369_175_30
clm
snippet
// connector-service/backend/common_utils/src/errors.rs pub field_names: String, /// Connector transaction reference id pub connector_transaction_id: Option<String>, } /// Event publisher errors. #[derive(Debug, thiserror::Error)] pub enum EventPublisherError { /// Failed to initialize Kafka writer #[error("Failed to initialize Kafka writer")] KafkaWriterInitializationFailed, /// Failed to serialize event data #[error("Failed to serialize event data")] EventSerializationFailed, /// Failed to publish event to Kafka #[error("Failed to publish event to Kafka")] EventPublishFailed, /// Invalid configuration provided #[error("Invalid configuration: {message}")] InvalidConfiguration { message: String }, /// Event publisher already initialized #[error("Event publisher already initialized")] AlreadyInitialized, /// Failed to process event transformations #[error("Failed to process event transformations")] EventProcessingFailed, /// Invalid path provided for nested value setting #[error("Invalid path provided: {path}")] InvalidPath { path: 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": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2179811235784210369_175_50
clm
snippet
// connector-service/backend/common_utils/src/errors.rs pub field_names: String, /// Connector transaction reference id pub connector_transaction_id: Option<String>, } /// Event publisher errors. #[derive(Debug, thiserror::Error)] pub enum EventPublisherError { /// Failed to initialize Kafka writer #[error("Failed to initialize Kafka writer")] KafkaWriterInitializationFailed, /// Failed to serialize event data #[error("Failed to serialize event data")] EventSerializationFailed, /// Failed to publish event to Kafka #[error("Failed to publish event to Kafka")] EventPublishFailed, /// Invalid configuration provided #[error("Invalid configuration: {message}")] InvalidConfiguration { message: String }, /// Event publisher already initialized #[error("Event publisher already initialized")] AlreadyInitialized, /// Failed to process event transformations #[error("Failed to process event transformations")] EventProcessingFailed, /// Invalid path provided for nested value setting #[error("Invalid path provided: {path}")] InvalidPath { path: 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": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_45732705880422454_0_15
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs //! Lineage ID domain types for tracking request lineage across services use std::collections::HashMap; /// A domain type representing lineage IDs as key-value pairs(uses hashmap internally). /// /// This type can deserialize only from URL-encoded format (e.g., "trace_id=123&span_id=456") #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct LineageIds<'a> { prefix: &'a str, inner: HashMap<String, String>, } impl<'a> LineageIds<'a> { /// Create a new LineageIds from prefix and URL-encoded 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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_45732705880422454_0_30
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs //! Lineage ID domain types for tracking request lineage across services use std::collections::HashMap; /// A domain type representing lineage IDs as key-value pairs(uses hashmap internally). /// /// This type can deserialize only from URL-encoded format (e.g., "trace_id=123&span_id=456") #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct LineageIds<'a> { prefix: &'a str, inner: HashMap<String, String>, } impl<'a> LineageIds<'a> { /// Create a new LineageIds from prefix and URL-encoded string pub fn new(prefix: &'a str, url_encoded_string: &str) -> Result<Self, LineageParseError> { Ok(Self { prefix, inner: serde_urlencoded::from_str(url_encoded_string) .map_err(|e| LineageParseError::InvalidFormat(e.to_string()))?, }) } /// Create a new empty LineageIds pub fn empty(prefix: &'a str) -> Self { Self { prefix, inner: 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": 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_45732705880422454_0_50
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs //! Lineage ID domain types for tracking request lineage across services use std::collections::HashMap; /// A domain type representing lineage IDs as key-value pairs(uses hashmap internally). /// /// This type can deserialize only from URL-encoded format (e.g., "trace_id=123&span_id=456") #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct LineageIds<'a> { prefix: &'a str, inner: HashMap<String, String>, } impl<'a> LineageIds<'a> { /// Create a new LineageIds from prefix and URL-encoded string pub fn new(prefix: &'a str, url_encoded_string: &str) -> Result<Self, LineageParseError> { Ok(Self { prefix, inner: serde_urlencoded::from_str(url_encoded_string) .map_err(|e| LineageParseError::InvalidFormat(e.to_string()))?, }) } /// Create a new empty LineageIds pub fn empty(prefix: &'a str) -> Self { Self { prefix, inner: HashMap::new(), } } /// Get the inner HashMap with prefixed keys pub fn inner(&self) -> HashMap<String, String> { self.inner .iter() .map(|(k, v)| (format!("{}{}", self.prefix, k), v.clone())) .collect() } /// Get the inner HashMap without prefix (raw keys) pub fn inner_raw(&self) -> &HashMap<String, String> { &self.inner } /// Convert to an owned LineageIds with 'static lifetime pub fn to_owned(&self) -> LineageIds<'static> { LineageIds { prefix: Box::leak(self.prefix.to_string().into_boxed_str()), inner: self.inner.clone(), }
{ "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_45732705880422454_25_15
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs Self { prefix, inner: HashMap::new(), } } /// Get the inner HashMap with prefixed keys pub fn inner(&self) -> HashMap<String, String> { self.inner .iter() .map(|(k, v)| (format!("{}{}", self.prefix, k), v.clone())) .collect() } /// Get the inner HashMap without prefix (raw 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": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_45732705880422454_25_30
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs Self { prefix, inner: HashMap::new(), } } /// Get the inner HashMap with prefixed keys pub fn inner(&self) -> HashMap<String, String> { self.inner .iter() .map(|(k, v)| (format!("{}{}", self.prefix, k), v.clone())) .collect() } /// Get the inner HashMap without prefix (raw keys) pub fn inner_raw(&self) -> &HashMap<String, String> { &self.inner } /// Convert to an owned LineageIds with 'static lifetime pub fn to_owned(&self) -> LineageIds<'static> { LineageIds { prefix: Box::leak(self.prefix.to_string().into_boxed_str()), inner: self.inner.clone(), } } } impl serde::Serialize for LineageIds<'_> { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
{ "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_45732705880422454_25_50
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs Self { prefix, inner: HashMap::new(), } } /// Get the inner HashMap with prefixed keys pub fn inner(&self) -> HashMap<String, String> { self.inner .iter() .map(|(k, v)| (format!("{}{}", self.prefix, k), v.clone())) .collect() } /// Get the inner HashMap without prefix (raw keys) pub fn inner_raw(&self) -> &HashMap<String, String> { &self.inner } /// Convert to an owned LineageIds with 'static lifetime pub fn to_owned(&self) -> LineageIds<'static> { LineageIds { prefix: Box::leak(self.prefix.to_string().into_boxed_str()), inner: self.inner.clone(), } } } impl serde::Serialize for LineageIds<'_> { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let prefixed_map = self.inner(); prefixed_map.serialize(serializer) } } /// Error type for lineage parsing operations #[derive(Debug, thiserror::Error)] pub enum LineageParseError { #[error("Invalid lineage header format: {0}")] InvalidFormat(String), #[error("URL decoding failed: {0}")] UrlDecoding(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": 45, "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_45732705880422454_50_15
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs } } impl serde::Serialize for LineageIds<'_> { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let prefixed_map = self.inner(); prefixed_map.serialize(serializer) } } /// Error type for lineage parsing operations #[derive(Debug, thiserror::Error)] pub enum LineageParseError {
{ "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_45732705880422454_50_30
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs } } impl serde::Serialize for LineageIds<'_> { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let prefixed_map = self.inner(); prefixed_map.serialize(serializer) } } /// Error type for lineage parsing operations #[derive(Debug, thiserror::Error)] pub enum LineageParseError { #[error("Invalid lineage header format: {0}")] InvalidFormat(String), #[error("URL decoding failed: {0}")] UrlDecoding(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": 20, "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_45732705880422454_50_50
clm
snippet
// connector-service/backend/common_utils/src/lineage.rs } } impl serde::Serialize for LineageIds<'_> { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let prefixed_map = self.inner(); prefixed_map.serialize(serializer) } } /// Error type for lineage parsing operations #[derive(Debug, thiserror::Error)] pub enum LineageParseError { #[error("Invalid lineage header format: {0}")] InvalidFormat(String), #[error("URL decoding failed: {0}")] UrlDecoding(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": 20, "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_-841769499540836508_0_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs //! Common ID types use std::{borrow::Cow, fmt::Debug}; use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::{ fp_utils::{generate_id_with_default_len, when}, CustomResult, ValidationError, }; /// A type for alphanumeric ids #[derive(Debug, PartialEq, Hash, Serialize, Clone, Eq)] pub(crate) struct AlphaNumericId(pub 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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_0_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs //! Common ID types use std::{borrow::Cow, fmt::Debug}; use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::{ fp_utils::{generate_id_with_default_len, when}, CustomResult, ValidationError, }; /// A type for alphanumeric ids #[derive(Debug, PartialEq, Hash, Serialize, Clone, Eq)] pub(crate) struct AlphaNumericId(pub String); impl AlphaNumericId { /// Generate a new alphanumeric id of default length pub(crate) fn new(prefix: &str) -> Self { Self(generate_id_with_default_len(prefix)) } } #[derive(Debug, Deserialize, Hash, Serialize, Error, Eq, PartialEq)] #[error("value `{0}` contains invalid character `{1}`")] /// The error type for alphanumeric id pub struct AlphaNumericIdError(String, char); impl<'de> Deserialize<'de> for AlphaNumericId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
{ "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_-841769499540836508_0_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs //! Common ID types use std::{borrow::Cow, fmt::Debug}; use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::{ fp_utils::{generate_id_with_default_len, when}, CustomResult, ValidationError, }; /// A type for alphanumeric ids #[derive(Debug, PartialEq, Hash, Serialize, Clone, Eq)] pub(crate) struct AlphaNumericId(pub String); impl AlphaNumericId { /// Generate a new alphanumeric id of default length pub(crate) fn new(prefix: &str) -> Self { Self(generate_id_with_default_len(prefix)) } } #[derive(Debug, Deserialize, Hash, Serialize, Error, Eq, PartialEq)] #[error("value `{0}` contains invalid character `{1}`")] /// The error type for alphanumeric id pub struct AlphaNumericIdError(String, char); impl<'de> Deserialize<'de> for AlphaNumericId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let deserialized_string = String::deserialize(deserializer)?; Self::from(deserialized_string.into()).map_err(serde::de::Error::custom) } } impl AlphaNumericId { /// Creates a new alphanumeric id from string by applying validation checks pub fn from(input_string: Cow<'static, str>) -> Result<Self, AlphaNumericIdError> { // For simplicity, we'll accept any string - in production you'd validate alphanumeric Ok(Self(input_string.to_string())) } /// Create a new alphanumeric id without any validations pub(crate) fn new_unchecked(input_string: String) -> Self { Self(input_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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_25_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// The error type for alphanumeric id pub struct AlphaNumericIdError(String, char); impl<'de> Deserialize<'de> for AlphaNumericId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let deserialized_string = String::deserialize(deserializer)?; Self::from(deserialized_string.into()).map_err(serde::de::Error::custom) } } impl AlphaNumericId { /// Creates a new alphanumeric id from string by applying validation checks
{ "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_-841769499540836508_25_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// The error type for alphanumeric id pub struct AlphaNumericIdError(String, char); impl<'de> Deserialize<'de> for AlphaNumericId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let deserialized_string = String::deserialize(deserializer)?; Self::from(deserialized_string.into()).map_err(serde::de::Error::custom) } } impl AlphaNumericId { /// Creates a new alphanumeric id from string by applying validation checks pub fn from(input_string: Cow<'static, str>) -> Result<Self, AlphaNumericIdError> { // For simplicity, we'll accept any string - in production you'd validate alphanumeric Ok(Self(input_string.to_string())) } /// Create a new alphanumeric id without any validations pub(crate) fn new_unchecked(input_string: String) -> Self { Self(input_string) } } /// Simple ID types for customer and merchant #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct CustomerId(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": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_25_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// The error type for alphanumeric id pub struct AlphaNumericIdError(String, char); impl<'de> Deserialize<'de> for AlphaNumericId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let deserialized_string = String::deserialize(deserializer)?; Self::from(deserialized_string.into()).map_err(serde::de::Error::custom) } } impl AlphaNumericId { /// Creates a new alphanumeric id from string by applying validation checks pub fn from(input_string: Cow<'static, str>) -> Result<Self, AlphaNumericIdError> { // For simplicity, we'll accept any string - in production you'd validate alphanumeric Ok(Self(input_string.to_string())) } /// Create a new alphanumeric id without any validations pub(crate) fn new_unchecked(input_string: String) -> Self { Self(input_string) } } /// Simple ID types for customer and merchant #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct CustomerId(String); impl Default for CustomerId { fn default() -> Self { Self("cus_default".to_string()) } } impl CustomerId { pub fn get_string_repr(&self) -> &str { &self.0 } } impl<'de> Deserialize<'de> for CustomerId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let s = String::deserialize(deserializer)?; Ok(Self(s)) }
{ "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_-841769499540836508_50_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Simple ID types for customer and merchant #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct CustomerId(String); impl Default for CustomerId { fn default() -> Self { Self("cus_default".to_string()) } } impl CustomerId { pub fn get_string_repr(&self) -> &str { &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": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_50_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Simple ID types for customer and merchant #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct CustomerId(String); impl Default for CustomerId { fn default() -> Self { Self("cus_default".to_string()) } } impl CustomerId { pub fn get_string_repr(&self) -> &str { &self.0 } } impl<'de> Deserialize<'de> for CustomerId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let s = String::deserialize(deserializer)?; Ok(Self(s)) } } impl FromStr for CustomerId { type Err = error_stack::Report<ValidationError>;
{ "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_-841769499540836508_50_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Simple ID types for customer and merchant #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct CustomerId(String); impl Default for CustomerId { fn default() -> Self { Self("cus_default".to_string()) } } impl CustomerId { pub fn get_string_repr(&self) -> &str { &self.0 } } impl<'de> Deserialize<'de> for CustomerId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let s = String::deserialize(deserializer)?; Ok(Self(s)) } } impl FromStr for CustomerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self(s.to_string())) } } impl TryFrom<Cow<'_, str>> for CustomerId { type Error = error_stack::Report<ValidationError>; fn try_from(value: Cow<'_, str>) -> Result<Self, Self::Error> { Ok(Self(value.to_string())) } } impl hyperswitch_masking::SerializableSecret for CustomerId {} #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct MerchantId(String); impl Default for 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": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_75_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs } impl FromStr for CustomerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self(s.to_string())) } } impl TryFrom<Cow<'_, str>> for CustomerId { type Error = error_stack::Report<ValidationError>; fn try_from(value: Cow<'_, str>) -> Result<Self, Self::Error> { Ok(Self(value.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": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_75_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs } impl FromStr for CustomerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self(s.to_string())) } } impl TryFrom<Cow<'_, str>> for CustomerId { type Error = error_stack::Report<ValidationError>; fn try_from(value: Cow<'_, str>) -> Result<Self, Self::Error> { Ok(Self(value.to_string())) } } impl hyperswitch_masking::SerializableSecret for CustomerId {} #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct MerchantId(String); impl Default for MerchantId { fn default() -> Self { Self("mer_default".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 }
connector-service_snippet_-841769499540836508_75_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs } impl FromStr for CustomerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self(s.to_string())) } } impl TryFrom<Cow<'_, str>> for CustomerId { type Error = error_stack::Report<ValidationError>; fn try_from(value: Cow<'_, str>) -> Result<Self, Self::Error> { Ok(Self(value.to_string())) } } impl hyperswitch_masking::SerializableSecret for CustomerId {} #[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)] pub struct MerchantId(String); impl Default for MerchantId { fn default() -> Self { Self("mer_default".to_string()) } } impl MerchantId { pub fn get_string_repr(&self) -> &str { &self.0 } } impl<'de> Deserialize<'de> for MerchantId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let s = String::deserialize(deserializer)?; Ok(Self(s)) } } impl FromStr for MerchantId { type Err = std::convert::Infallible; fn from_str(s: &str) -> Result<Self, Self::Err> {
{ "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_-841769499540836508_100_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs fn default() -> Self { Self("mer_default".to_string()) } } impl MerchantId { pub fn get_string_repr(&self) -> &str { &self.0 } } impl<'de> Deserialize<'de> for MerchantId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>,
{ "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_-841769499540836508_100_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs fn default() -> Self { Self("mer_default".to_string()) } } impl MerchantId { pub fn get_string_repr(&self) -> &str { &self.0 } } impl<'de> Deserialize<'de> for MerchantId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let s = String::deserialize(deserializer)?; Ok(Self(s)) } } impl FromStr for MerchantId { type Err = std::convert::Infallible; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self(s.to_string())) } } crate::id_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": 100, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_100_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs fn default() -> Self { Self("mer_default".to_string()) } } impl MerchantId { pub fn get_string_repr(&self) -> &str { &self.0 } } impl<'de> Deserialize<'de> for MerchantId { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let s = String::deserialize(deserializer)?; Ok(Self(s)) } } impl FromStr for MerchantId { type Err = std::convert::Infallible; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self(s.to_string())) } } crate::id_type!( PaymentId, "A type for payment_id that can be used for payment ids" ); crate::impl_id_type_methods!(PaymentId, "payment_id"); // This is to display the `PaymentId` as PaymentId(abcd) crate::impl_debug_id_type!(PaymentId); crate::impl_default_id_type!(PaymentId, "pay"); crate::impl_try_from_cow_str_id_type!(PaymentId, "payment_id"); impl PaymentId { /// Get the hash key to be stored in redis pub fn get_hash_key_for_kv_store(&self) -> String { format!("pi_{}", self.0 .0 .0) } // This function should be removed once we have a better way to handle mandatory payment id in other flows /// Get payment id in the format of irrelevant_payment_id_in_{flow} pub fn get_irrelevant_id(flow: &str) -> Self { let alphanumeric_id =
{ "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_-841769499540836508_125_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs Ok(Self(s.to_string())) } } crate::id_type!( PaymentId, "A type for payment_id that can be used for payment ids" ); crate::impl_id_type_methods!(PaymentId, "payment_id"); // This is to display the `PaymentId` as PaymentId(abcd) crate::impl_debug_id_type!(PaymentId); crate::impl_default_id_type!(PaymentId, "pay"); crate::impl_try_from_cow_str_id_type!(PaymentId, "payment_id");
{ "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_-841769499540836508_125_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs Ok(Self(s.to_string())) } } crate::id_type!( PaymentId, "A type for payment_id that can be used for payment ids" ); crate::impl_id_type_methods!(PaymentId, "payment_id"); // This is to display the `PaymentId` as PaymentId(abcd) crate::impl_debug_id_type!(PaymentId); crate::impl_default_id_type!(PaymentId, "pay"); crate::impl_try_from_cow_str_id_type!(PaymentId, "payment_id"); impl PaymentId { /// Get the hash key to be stored in redis pub fn get_hash_key_for_kv_store(&self) -> String { format!("pi_{}", self.0 .0 .0) } // This function should be removed once we have a better way to handle mandatory payment id in other flows /// Get payment id in the format of irrelevant_payment_id_in_{flow} pub fn get_irrelevant_id(flow: &str) -> Self { let alphanumeric_id = AlphaNumericId::new_unchecked(format!("irrelevant_payment_id_in_{flow}")); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) }
{ "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_-841769499540836508_125_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs Ok(Self(s.to_string())) } } crate::id_type!( PaymentId, "A type for payment_id that can be used for payment ids" ); crate::impl_id_type_methods!(PaymentId, "payment_id"); // This is to display the `PaymentId` as PaymentId(abcd) crate::impl_debug_id_type!(PaymentId); crate::impl_default_id_type!(PaymentId, "pay"); crate::impl_try_from_cow_str_id_type!(PaymentId, "payment_id"); impl PaymentId { /// Get the hash key to be stored in redis pub fn get_hash_key_for_kv_store(&self) -> String { format!("pi_{}", self.0 .0 .0) } // This function should be removed once we have a better way to handle mandatory payment id in other flows /// Get payment id in the format of irrelevant_payment_id_in_{flow} pub fn get_irrelevant_id(flow: &str) -> Self { let alphanumeric_id = AlphaNumericId::new_unchecked(format!("irrelevant_payment_id_in_{flow}")); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Get the attempt id for the payment id based on the attempt count pub fn get_attempt_id(&self, attempt_count: i16) -> String { format!("{}_{attempt_count}", self.get_string_repr()) } /// Generate a client id for the payment id pub fn generate_client_secret(&self) -> String { generate_id_with_default_len(&format!("{}_secret", self.get_string_repr())) } /// Generate a key for pm_auth pub fn get_pm_auth_key(&self) -> String { format!("pm_auth_{}", self.get_string_repr()) } /// Get external authentication request poll id pub fn get_external_authentication_request_poll_id(&self) -> String { format!("external_authentication_{}", self.get_string_repr()) }
{ "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_-841769499540836508_150_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs AlphaNumericId::new_unchecked(format!("irrelevant_payment_id_in_{flow}")); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Get the attempt id for the payment id based on the attempt count pub fn get_attempt_id(&self, attempt_count: i16) -> String { format!("{}_{attempt_count}", self.get_string_repr()) } /// Generate a client id for the payment id pub fn generate_client_secret(&self) -> String { generate_id_with_default_len(&format!("{}_secret", self.get_string_repr())) }
{ "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_-841769499540836508_150_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs AlphaNumericId::new_unchecked(format!("irrelevant_payment_id_in_{flow}")); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Get the attempt id for the payment id based on the attempt count pub fn get_attempt_id(&self, attempt_count: i16) -> String { format!("{}_{attempt_count}", self.get_string_repr()) } /// Generate a client id for the payment id pub fn generate_client_secret(&self) -> String { generate_id_with_default_len(&format!("{}_secret", self.get_string_repr())) } /// Generate a key for pm_auth pub fn get_pm_auth_key(&self) -> String { format!("pm_auth_{}", self.get_string_repr()) } /// Get external authentication request poll id pub fn get_external_authentication_request_poll_id(&self) -> String { format!("external_authentication_{}", self.get_string_repr()) } /// Generate a test payment id with prefix test_ pub fn generate_test_payment_id_for_sample_data() -> Self { let id = generate_id_with_default_len("test"); let alphanumeric_id = AlphaNumericId::new_unchecked(id); let id = LengthId::new_unchecked(alphanumeric_id);
{ "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_-841769499540836508_150_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs AlphaNumericId::new_unchecked(format!("irrelevant_payment_id_in_{flow}")); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Get the attempt id for the payment id based on the attempt count pub fn get_attempt_id(&self, attempt_count: i16) -> String { format!("{}_{attempt_count}", self.get_string_repr()) } /// Generate a client id for the payment id pub fn generate_client_secret(&self) -> String { generate_id_with_default_len(&format!("{}_secret", self.get_string_repr())) } /// Generate a key for pm_auth pub fn get_pm_auth_key(&self) -> String { format!("pm_auth_{}", self.get_string_repr()) } /// Get external authentication request poll id pub fn get_external_authentication_request_poll_id(&self) -> String { format!("external_authentication_{}", self.get_string_repr()) } /// Generate a test payment id with prefix test_ pub fn generate_test_payment_id_for_sample_data() -> Self { let id = generate_id_with_default_len("test"); let alphanumeric_id = AlphaNumericId::new_unchecked(id); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Wrap a string inside PaymentId pub fn wrap(payment_id_string: String) -> CustomResult<Self, ValidationError> { Self::try_from(Cow::from(payment_id_string)) } } #[derive(Debug, Clone, Serialize, Hash, Deserialize, PartialEq, Eq)] pub(crate) struct LengthId<const MAX_LENGTH: u8, const MIN_LENGTH: u8>(pub AlphaNumericId); impl<const MAX_LENGTH: u8, const MIN_LENGTH: u8> LengthId<MAX_LENGTH, MIN_LENGTH> { /// Generates new [MerchantReferenceId] from the given input string pub fn from(input_string: Cow<'static, str>) -> Result<Self, LengthIdError> { let trimmed_input_string = input_string.trim().to_string(); let length_of_input_string = u8::try_from(trimmed_input_string.len()) .map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?;
{ "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_-841769499540836508_175_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Generate a test payment id with prefix test_ pub fn generate_test_payment_id_for_sample_data() -> Self { let id = generate_id_with_default_len("test"); let alphanumeric_id = AlphaNumericId::new_unchecked(id); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Wrap a string inside PaymentId pub fn wrap(payment_id_string: String) -> CustomResult<Self, ValidationError> { Self::try_from(Cow::from(payment_id_string)) } } #[derive(Debug, Clone, Serialize, Hash, Deserialize, PartialEq, Eq)]
{ "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_-841769499540836508_175_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Generate a test payment id with prefix test_ pub fn generate_test_payment_id_for_sample_data() -> Self { let id = generate_id_with_default_len("test"); let alphanumeric_id = AlphaNumericId::new_unchecked(id); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Wrap a string inside PaymentId pub fn wrap(payment_id_string: String) -> CustomResult<Self, ValidationError> { Self::try_from(Cow::from(payment_id_string)) } } #[derive(Debug, Clone, Serialize, Hash, Deserialize, PartialEq, Eq)] pub(crate) struct LengthId<const MAX_LENGTH: u8, const MIN_LENGTH: u8>(pub AlphaNumericId); impl<const MAX_LENGTH: u8, const MIN_LENGTH: u8> LengthId<MAX_LENGTH, MIN_LENGTH> { /// Generates new [MerchantReferenceId] from the given input string pub fn from(input_string: Cow<'static, str>) -> Result<Self, LengthIdError> { let trimmed_input_string = input_string.trim().to_string(); let length_of_input_string = u8::try_from(trimmed_input_string.len()) .map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?; when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || {
{ "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_-841769499540836508_175_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Generate a test payment id with prefix test_ pub fn generate_test_payment_id_for_sample_data() -> Self { let id = generate_id_with_default_len("test"); let alphanumeric_id = AlphaNumericId::new_unchecked(id); let id = LengthId::new_unchecked(alphanumeric_id); Self(id) } /// Wrap a string inside PaymentId pub fn wrap(payment_id_string: String) -> CustomResult<Self, ValidationError> { Self::try_from(Cow::from(payment_id_string)) } } #[derive(Debug, Clone, Serialize, Hash, Deserialize, PartialEq, Eq)] pub(crate) struct LengthId<const MAX_LENGTH: u8, const MIN_LENGTH: u8>(pub AlphaNumericId); impl<const MAX_LENGTH: u8, const MIN_LENGTH: u8> LengthId<MAX_LENGTH, MIN_LENGTH> { /// Generates new [MerchantReferenceId] from the given input string pub fn from(input_string: Cow<'static, str>) -> Result<Self, LengthIdError> { let trimmed_input_string = input_string.trim().to_string(); let length_of_input_string = u8::try_from(trimmed_input_string.len()) .map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?; when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH)) })?; let alphanumeric_id = match AlphaNumericId::from(trimmed_input_string.into()) { Ok(valid_alphanumeric_id) => valid_alphanumeric_id, Err(error) => Err(LengthIdError::AlphanumericIdError(error))?, }; Ok(Self(alphanumeric_id)) } /// Generate a new MerchantRefId of default length with the given prefix pub fn new(prefix: &str) -> Self { Self(AlphaNumericId::new(prefix)) } /// Use this function only if you are sure that the length is within the range pub(crate) fn new_unchecked(alphanumeric_id: AlphaNumericId) -> Self { Self(alphanumeric_id) }
{ "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_-841769499540836508_200_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH)) })?; let alphanumeric_id = match AlphaNumericId::from(trimmed_input_string.into()) { Ok(valid_alphanumeric_id) => valid_alphanumeric_id, Err(error) => Err(LengthIdError::AlphanumericIdError(error))?, }; Ok(Self(alphanumeric_id)) }
{ "chunk": null, "crate": "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_-841769499540836508_200_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH)) })?; let alphanumeric_id = match AlphaNumericId::from(trimmed_input_string.into()) { Ok(valid_alphanumeric_id) => valid_alphanumeric_id, Err(error) => Err(LengthIdError::AlphanumericIdError(error))?, }; Ok(Self(alphanumeric_id)) } /// Generate a new MerchantRefId of default length with the given prefix pub fn new(prefix: &str) -> Self { Self(AlphaNumericId::new(prefix)) } /// Use this function only if you are sure that the length is within the range pub(crate) fn new_unchecked(alphanumeric_id: AlphaNumericId) -> Self { Self(alphanumeric_id) } /// Create a new LengthId from aplhanumeric id pub(crate) fn from_alphanumeric_id( alphanumeric_id: AlphaNumericId, ) -> Result<Self, LengthIdError> {
{ "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_-841769499540836508_200_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH)) })?; let alphanumeric_id = match AlphaNumericId::from(trimmed_input_string.into()) { Ok(valid_alphanumeric_id) => valid_alphanumeric_id, Err(error) => Err(LengthIdError::AlphanumericIdError(error))?, }; Ok(Self(alphanumeric_id)) } /// Generate a new MerchantRefId of default length with the given prefix pub fn new(prefix: &str) -> Self { Self(AlphaNumericId::new(prefix)) } /// Use this function only if you are sure that the length is within the range pub(crate) fn new_unchecked(alphanumeric_id: AlphaNumericId) -> Self { Self(alphanumeric_id) } /// Create a new LengthId from aplhanumeric id pub(crate) fn from_alphanumeric_id( alphanumeric_id: AlphaNumericId, ) -> Result<Self, LengthIdError> { let length_of_input_string = alphanumeric_id.0.len(); let length_of_input_string = u8::try_from(length_of_input_string) .map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?; when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH)) })?; Ok(Self(alphanumeric_id)) } } #[derive(Debug, Error, PartialEq, Eq)] pub enum LengthIdError { #[error("the maximum allowed length for this field is {0}")] /// Maximum length of string violated
{ "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_-841769499540836508_225_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Create a new LengthId from aplhanumeric id pub(crate) fn from_alphanumeric_id( alphanumeric_id: AlphaNumericId, ) -> Result<Self, LengthIdError> { let length_of_input_string = alphanumeric_id.0.len(); let length_of_input_string = u8::try_from(length_of_input_string) .map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?; when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH))
{ "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_-841769499540836508_225_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Create a new LengthId from aplhanumeric id pub(crate) fn from_alphanumeric_id( alphanumeric_id: AlphaNumericId, ) -> Result<Self, LengthIdError> { let length_of_input_string = alphanumeric_id.0.len(); let length_of_input_string = u8::try_from(length_of_input_string) .map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?; when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH)) })?; Ok(Self(alphanumeric_id)) } } #[derive(Debug, Error, PartialEq, Eq)] pub enum LengthIdError { #[error("the maximum allowed length for this field is {0}")] /// Maximum length of string violated MaxLengthViolated(u8), #[error("the minimum required length for this field is {0}")] /// Minimum length of string violated MinLengthViolated(u8),
{ "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_-841769499540836508_225_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs /// Create a new LengthId from aplhanumeric id pub(crate) fn from_alphanumeric_id( alphanumeric_id: AlphaNumericId, ) -> Result<Self, LengthIdError> { let length_of_input_string = alphanumeric_id.0.len(); let length_of_input_string = u8::try_from(length_of_input_string) .map_err(|_| LengthIdError::MaxLengthViolated(MAX_LENGTH))?; when(length_of_input_string > MAX_LENGTH, || { Err(LengthIdError::MaxLengthViolated(MAX_LENGTH)) })?; when(length_of_input_string < MIN_LENGTH, || { Err(LengthIdError::MinLengthViolated(MIN_LENGTH)) })?; Ok(Self(alphanumeric_id)) } } #[derive(Debug, Error, PartialEq, Eq)] pub enum LengthIdError { #[error("the maximum allowed length for this field is {0}")] /// Maximum length of string violated MaxLengthViolated(u8), #[error("the minimum required length for this field is {0}")] /// Minimum length of string violated MinLengthViolated(u8), #[error("{0}")] /// Input contains invalid characters AlphanumericIdError(AlphaNumericIdError), } impl From<AlphaNumericIdError> for LengthIdError { fn from(alphanumeric_id_error: AlphaNumericIdError) -> Self { Self::AlphanumericIdError(alphanumeric_id_error) } } use std::str::FromStr; crate::id_type!( ProfileId, "A type for profile_id that can be used for business profile ids" ); crate::impl_id_type_methods!(ProfileId, "profile_id");
{ "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_-841769499540836508_250_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs MaxLengthViolated(u8), #[error("the minimum required length for this field is {0}")] /// Minimum length of string violated MinLengthViolated(u8), #[error("{0}")] /// Input contains invalid characters AlphanumericIdError(AlphaNumericIdError), } impl From<AlphaNumericIdError> for LengthIdError { fn from(alphanumeric_id_error: AlphaNumericIdError) -> Self { Self::AlphanumericIdError(alphanumeric_id_error) }
{ "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_-841769499540836508_250_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs MaxLengthViolated(u8), #[error("the minimum required length for this field is {0}")] /// Minimum length of string violated MinLengthViolated(u8), #[error("{0}")] /// Input contains invalid characters AlphanumericIdError(AlphaNumericIdError), } impl From<AlphaNumericIdError> for LengthIdError { fn from(alphanumeric_id_error: AlphaNumericIdError) -> Self { Self::AlphanumericIdError(alphanumeric_id_error) } } use std::str::FromStr; crate::id_type!( ProfileId, "A type for profile_id that can be used for business profile ids" ); crate::impl_id_type_methods!(ProfileId, "profile_id"); // This is to display the `ProfileId` as ProfileId(abcd) crate::impl_debug_id_type!(ProfileId); crate::impl_try_from_cow_str_id_type!(ProfileId, "profile_id"); crate::impl_generate_id_id_type!(ProfileId, "pro");
{ "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_-841769499540836508_250_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs MaxLengthViolated(u8), #[error("the minimum required length for this field is {0}")] /// Minimum length of string violated MinLengthViolated(u8), #[error("{0}")] /// Input contains invalid characters AlphanumericIdError(AlphaNumericIdError), } impl From<AlphaNumericIdError> for LengthIdError { fn from(alphanumeric_id_error: AlphaNumericIdError) -> Self { Self::AlphanumericIdError(alphanumeric_id_error) } } use std::str::FromStr; crate::id_type!( ProfileId, "A type for profile_id that can be used for business profile ids" ); crate::impl_id_type_methods!(ProfileId, "profile_id"); // This is to display the `ProfileId` as ProfileId(abcd) crate::impl_debug_id_type!(ProfileId); crate::impl_try_from_cow_str_id_type!(ProfileId, "profile_id"); crate::impl_generate_id_id_type!(ProfileId, "pro"); crate::impl_serializable_secret_id_type!(ProfileId); impl crate::events::ApiEventMetric for ProfileId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::BusinessProfile { profile_id: self.clone(), }) } } impl FromStr for ProfileId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = Cow::Owned(s.to_string()); Self::try_from(cow_string) } } /// An interface to generate object identifiers.
{ "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_-841769499540836508_275_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs // This is to display the `ProfileId` as ProfileId(abcd) crate::impl_debug_id_type!(ProfileId); crate::impl_try_from_cow_str_id_type!(ProfileId, "profile_id"); crate::impl_generate_id_id_type!(ProfileId, "pro"); crate::impl_serializable_secret_id_type!(ProfileId); impl crate::events::ApiEventMetric for ProfileId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::BusinessProfile { profile_id: self.clone(), }) } }
{ "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_-841769499540836508_275_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs // This is to display the `ProfileId` as ProfileId(abcd) crate::impl_debug_id_type!(ProfileId); crate::impl_try_from_cow_str_id_type!(ProfileId, "profile_id"); crate::impl_generate_id_id_type!(ProfileId, "pro"); crate::impl_serializable_secret_id_type!(ProfileId); impl crate::events::ApiEventMetric for ProfileId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::BusinessProfile { profile_id: self.clone(), }) } } impl FromStr for ProfileId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = Cow::Owned(s.to_string()); Self::try_from(cow_string) } } /// An interface to generate object identifiers. pub trait GenerateId { /// Generates a random object identifier. fn generate() -> 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": 275, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_275_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs // This is to display the `ProfileId` as ProfileId(abcd) crate::impl_debug_id_type!(ProfileId); crate::impl_try_from_cow_str_id_type!(ProfileId, "profile_id"); crate::impl_generate_id_id_type!(ProfileId, "pro"); crate::impl_serializable_secret_id_type!(ProfileId); impl crate::events::ApiEventMetric for ProfileId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::BusinessProfile { profile_id: self.clone(), }) } } impl FromStr for ProfileId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = Cow::Owned(s.to_string()); Self::try_from(cow_string) } } /// An interface to generate object identifiers. pub trait GenerateId { /// Generates a random object identifier. fn generate() -> Self; } crate::id_type!( ClientSecretId, "A type for key_id that can be used for Ephemeral key IDs" ); crate::impl_id_type_methods!(ClientSecretId, "key_id"); // This is to display the `ClientSecretId` as ClientSecretId(abcd) crate::impl_debug_id_type!(ClientSecretId); crate::impl_try_from_cow_str_id_type!(ClientSecretId, "key_id"); crate::impl_generate_id_id_type!(ClientSecretId, "csi"); crate::impl_serializable_secret_id_type!(ClientSecretId); impl crate::events::ApiEventMetric for ClientSecretId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ClientSecret { key_id: self.clone(), }) } }
{ "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_-841769499540836508_300_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs pub trait GenerateId { /// Generates a random object identifier. fn generate() -> Self; } crate::id_type!( ClientSecretId, "A type for key_id that can be used for Ephemeral key IDs" ); crate::impl_id_type_methods!(ClientSecretId, "key_id"); // This is to display the `ClientSecretId` as ClientSecretId(abcd) crate::impl_debug_id_type!(ClientSecretId); crate::impl_try_from_cow_str_id_type!(ClientSecretId, "key_id");
{ "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_-841769499540836508_300_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs pub trait GenerateId { /// Generates a random object identifier. fn generate() -> Self; } crate::id_type!( ClientSecretId, "A type for key_id that can be used for Ephemeral key IDs" ); crate::impl_id_type_methods!(ClientSecretId, "key_id"); // This is to display the `ClientSecretId` as ClientSecretId(abcd) crate::impl_debug_id_type!(ClientSecretId); crate::impl_try_from_cow_str_id_type!(ClientSecretId, "key_id"); crate::impl_generate_id_id_type!(ClientSecretId, "csi"); crate::impl_serializable_secret_id_type!(ClientSecretId); impl crate::events::ApiEventMetric for ClientSecretId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ClientSecret { key_id: self.clone(), }) } } crate::impl_default_id_type!(ClientSecretId, "key"); impl ClientSecretId { /// Generate a key for redis
{ "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_-841769499540836508_300_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs pub trait GenerateId { /// Generates a random object identifier. fn generate() -> Self; } crate::id_type!( ClientSecretId, "A type for key_id that can be used for Ephemeral key IDs" ); crate::impl_id_type_methods!(ClientSecretId, "key_id"); // This is to display the `ClientSecretId` as ClientSecretId(abcd) crate::impl_debug_id_type!(ClientSecretId); crate::impl_try_from_cow_str_id_type!(ClientSecretId, "key_id"); crate::impl_generate_id_id_type!(ClientSecretId, "csi"); crate::impl_serializable_secret_id_type!(ClientSecretId); impl crate::events::ApiEventMetric for ClientSecretId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ClientSecret { key_id: self.clone(), }) } } crate::impl_default_id_type!(ClientSecretId, "key"); impl ClientSecretId { /// Generate a key for redis pub fn generate_redis_key(&self) -> String { format!("cs_{}", self.get_string_repr()) } } crate::id_type!( ApiKeyId, "A type for key_id that can be used for API key IDs" ); crate::impl_id_type_methods!(ApiKeyId, "key_id"); // This is to display the `ApiKeyId` as ApiKeyId(abcd) crate::impl_debug_id_type!(ApiKeyId); crate::impl_try_from_cow_str_id_type!(ApiKeyId, "key_id"); crate::impl_serializable_secret_id_type!(ApiKeyId); impl ApiKeyId { /// Generate Api Key Id from prefix pub fn generate_key_id(prefix: &'static str) -> 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": 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_-841769499540836508_325_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs crate::impl_default_id_type!(ClientSecretId, "key"); impl ClientSecretId { /// Generate a key for redis pub fn generate_redis_key(&self) -> String { format!("cs_{}", self.get_string_repr()) } } crate::id_type!( ApiKeyId, "A type for key_id that can be used for API key IDs" ); crate::impl_id_type_methods!(ApiKeyId, "key_id");
{ "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_-841769499540836508_325_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs crate::impl_default_id_type!(ClientSecretId, "key"); impl ClientSecretId { /// Generate a key for redis pub fn generate_redis_key(&self) -> String { format!("cs_{}", self.get_string_repr()) } } crate::id_type!( ApiKeyId, "A type for key_id that can be used for API key IDs" ); crate::impl_id_type_methods!(ApiKeyId, "key_id"); // This is to display the `ApiKeyId` as ApiKeyId(abcd) crate::impl_debug_id_type!(ApiKeyId); crate::impl_try_from_cow_str_id_type!(ApiKeyId, "key_id"); crate::impl_serializable_secret_id_type!(ApiKeyId); impl ApiKeyId { /// Generate Api Key Id from prefix pub fn generate_key_id(prefix: &'static str) -> Self { Self(crate::generate_ref_id_with_default_length(prefix)) } } impl crate::events::ApiEventMetric for ApiKeyId {
{ "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_-841769499540836508_325_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs crate::impl_default_id_type!(ClientSecretId, "key"); impl ClientSecretId { /// Generate a key for redis pub fn generate_redis_key(&self) -> String { format!("cs_{}", self.get_string_repr()) } } crate::id_type!( ApiKeyId, "A type for key_id that can be used for API key IDs" ); crate::impl_id_type_methods!(ApiKeyId, "key_id"); // This is to display the `ApiKeyId` as ApiKeyId(abcd) crate::impl_debug_id_type!(ApiKeyId); crate::impl_try_from_cow_str_id_type!(ApiKeyId, "key_id"); crate::impl_serializable_secret_id_type!(ApiKeyId); impl ApiKeyId { /// Generate Api Key Id from prefix pub fn generate_key_id(prefix: &'static str) -> Self { Self(crate::generate_ref_id_with_default_length(prefix)) } } impl crate::events::ApiEventMetric for ApiKeyId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.clone(), }) } } impl crate::events::ApiEventMetric for (MerchantId, ApiKeyId) { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.1.clone(), }) } } impl crate::events::ApiEventMetric for (&MerchantId, &ApiKeyId) { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.1.clone(), })
{ "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_-841769499540836508_350_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs Self(crate::generate_ref_id_with_default_length(prefix)) } } impl crate::events::ApiEventMetric for ApiKeyId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.clone(), }) } } impl crate::events::ApiEventMetric for (MerchantId, ApiKeyId) { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey {
{ "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_-841769499540836508_350_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs Self(crate::generate_ref_id_with_default_length(prefix)) } } impl crate::events::ApiEventMetric for ApiKeyId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.clone(), }) } } impl crate::events::ApiEventMetric for (MerchantId, ApiKeyId) { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.1.clone(), }) } } impl crate::events::ApiEventMetric for (&MerchantId, &ApiKeyId) { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.1.clone(), }) } } crate::impl_default_id_type!(ApiKeyId, "key");
{ "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_-841769499540836508_350_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs Self(crate::generate_ref_id_with_default_length(prefix)) } } impl crate::events::ApiEventMetric for ApiKeyId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.clone(), }) } } impl crate::events::ApiEventMetric for (MerchantId, ApiKeyId) { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.1.clone(), }) } } impl crate::events::ApiEventMetric for (&MerchantId, &ApiKeyId) { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ApiKey { key_id: self.1.clone(), }) } } crate::impl_default_id_type!(ApiKeyId, "key"); crate::id_type!( MerchantConnectorAccountId, "A type for merchant_connector_id that can be used for merchant_connector_account ids" ); crate::impl_id_type_methods!(MerchantConnectorAccountId, "merchant_connector_id"); // This is to display the `MerchantConnectorAccountId` as MerchantConnectorAccountId(abcd) crate::impl_debug_id_type!(MerchantConnectorAccountId); crate::impl_generate_id_id_type!(MerchantConnectorAccountId, "mca"); crate::impl_try_from_cow_str_id_type!(MerchantConnectorAccountId, "merchant_connector_id"); crate::impl_serializable_secret_id_type!(MerchantConnectorAccountId); impl MerchantConnectorAccountId { /// Get a merchant connector account id from String pub fn wrap(merchant_connector_account_id: String) -> CustomResult<Self, ValidationError> { Self::try_from(Cow::from(merchant_connector_account_id)) } }
{ "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_-841769499540836508_375_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs } } crate::impl_default_id_type!(ApiKeyId, "key"); crate::id_type!( MerchantConnectorAccountId, "A type for merchant_connector_id that can be used for merchant_connector_account ids" ); crate::impl_id_type_methods!(MerchantConnectorAccountId, "merchant_connector_id"); // This is to display the `MerchantConnectorAccountId` as MerchantConnectorAccountId(abcd) crate::impl_debug_id_type!(MerchantConnectorAccountId); crate::impl_generate_id_id_type!(MerchantConnectorAccountId, "mca"); crate::impl_try_from_cow_str_id_type!(MerchantConnectorAccountId, "merchant_connector_id");
{ "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_-841769499540836508_375_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs } } crate::impl_default_id_type!(ApiKeyId, "key"); crate::id_type!( MerchantConnectorAccountId, "A type for merchant_connector_id that can be used for merchant_connector_account ids" ); crate::impl_id_type_methods!(MerchantConnectorAccountId, "merchant_connector_id"); // This is to display the `MerchantConnectorAccountId` as MerchantConnectorAccountId(abcd) crate::impl_debug_id_type!(MerchantConnectorAccountId); crate::impl_generate_id_id_type!(MerchantConnectorAccountId, "mca"); crate::impl_try_from_cow_str_id_type!(MerchantConnectorAccountId, "merchant_connector_id"); crate::impl_serializable_secret_id_type!(MerchantConnectorAccountId); impl MerchantConnectorAccountId { /// Get a merchant connector account id from String pub fn wrap(merchant_connector_account_id: String) -> CustomResult<Self, ValidationError> { Self::try_from(Cow::from(merchant_connector_account_id)) } } crate::id_type!( ProfileAcquirerId, "A type for profile_acquirer_id that can be used for profile acquirer ids" ); crate::impl_id_type_methods!(ProfileAcquirerId, "profile_acquirer_id");
{ "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_-841769499540836508_375_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs } } crate::impl_default_id_type!(ApiKeyId, "key"); crate::id_type!( MerchantConnectorAccountId, "A type for merchant_connector_id that can be used for merchant_connector_account ids" ); crate::impl_id_type_methods!(MerchantConnectorAccountId, "merchant_connector_id"); // This is to display the `MerchantConnectorAccountId` as MerchantConnectorAccountId(abcd) crate::impl_debug_id_type!(MerchantConnectorAccountId); crate::impl_generate_id_id_type!(MerchantConnectorAccountId, "mca"); crate::impl_try_from_cow_str_id_type!(MerchantConnectorAccountId, "merchant_connector_id"); crate::impl_serializable_secret_id_type!(MerchantConnectorAccountId); impl MerchantConnectorAccountId { /// Get a merchant connector account id from String pub fn wrap(merchant_connector_account_id: String) -> CustomResult<Self, ValidationError> { Self::try_from(Cow::from(merchant_connector_account_id)) } } crate::id_type!( ProfileAcquirerId, "A type for profile_acquirer_id that can be used for profile acquirer ids" ); crate::impl_id_type_methods!(ProfileAcquirerId, "profile_acquirer_id"); // This is to display the `ProfileAcquirerId` as ProfileAcquirerId(abcd) crate::impl_debug_id_type!(ProfileAcquirerId); crate::impl_try_from_cow_str_id_type!(ProfileAcquirerId, "profile_acquirer_id"); crate::impl_generate_id_id_type!(ProfileAcquirerId, "pro_acq"); crate::impl_serializable_secret_id_type!(ProfileAcquirerId); impl Ord for ProfileAcquirerId { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.0 .0 .0.cmp(&other.0 .0 .0) } } impl PartialOrd for ProfileAcquirerId { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { Some(self.cmp(other)) } }
{ "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_-841769499540836508_400_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs crate::id_type!( ProfileAcquirerId, "A type for profile_acquirer_id that can be used for profile acquirer ids" ); crate::impl_id_type_methods!(ProfileAcquirerId, "profile_acquirer_id"); // This is to display the `ProfileAcquirerId` as ProfileAcquirerId(abcd) crate::impl_debug_id_type!(ProfileAcquirerId); crate::impl_try_from_cow_str_id_type!(ProfileAcquirerId, "profile_acquirer_id"); crate::impl_generate_id_id_type!(ProfileAcquirerId, "pro_acq"); crate::impl_serializable_secret_id_type!(ProfileAcquirerId); impl Ord for ProfileAcquirerId { fn cmp(&self, other: &Self) -> std::cmp::Ordering {
{ "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_-841769499540836508_400_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs crate::id_type!( ProfileAcquirerId, "A type for profile_acquirer_id that can be used for profile acquirer ids" ); crate::impl_id_type_methods!(ProfileAcquirerId, "profile_acquirer_id"); // This is to display the `ProfileAcquirerId` as ProfileAcquirerId(abcd) crate::impl_debug_id_type!(ProfileAcquirerId); crate::impl_try_from_cow_str_id_type!(ProfileAcquirerId, "profile_acquirer_id"); crate::impl_generate_id_id_type!(ProfileAcquirerId, "pro_acq"); crate::impl_serializable_secret_id_type!(ProfileAcquirerId); impl Ord for ProfileAcquirerId { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.0 .0 .0.cmp(&other.0 .0 .0) } } impl PartialOrd for ProfileAcquirerId { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { Some(self.cmp(other)) } } impl crate::events::ApiEventMetric for ProfileAcquirerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ProfileAcquirer { profile_acquirer_id: self.clone(), })
{ "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_-841769499540836508_400_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs crate::id_type!( ProfileAcquirerId, "A type for profile_acquirer_id that can be used for profile acquirer ids" ); crate::impl_id_type_methods!(ProfileAcquirerId, "profile_acquirer_id"); // This is to display the `ProfileAcquirerId` as ProfileAcquirerId(abcd) crate::impl_debug_id_type!(ProfileAcquirerId); crate::impl_try_from_cow_str_id_type!(ProfileAcquirerId, "profile_acquirer_id"); crate::impl_generate_id_id_type!(ProfileAcquirerId, "pro_acq"); crate::impl_serializable_secret_id_type!(ProfileAcquirerId); impl Ord for ProfileAcquirerId { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.0 .0 .0.cmp(&other.0 .0 .0) } } impl PartialOrd for ProfileAcquirerId { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { Some(self.cmp(other)) } } impl crate::events::ApiEventMetric for ProfileAcquirerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ProfileAcquirer { profile_acquirer_id: self.clone(), }) } } impl FromStr for ProfileAcquirerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = Cow::Owned(s.to_string()); Self::try_from(cow_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": 41, "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_-841769499540836508_425_15
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs impl crate::events::ApiEventMetric for ProfileAcquirerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ProfileAcquirer { profile_acquirer_id: self.clone(), }) } } impl FromStr for ProfileAcquirerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = Cow::Owned(s.to_string()); Self::try_from(cow_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": 425, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-841769499540836508_425_30
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs impl crate::events::ApiEventMetric for ProfileAcquirerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ProfileAcquirer { profile_acquirer_id: self.clone(), }) } } impl FromStr for ProfileAcquirerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = Cow::Owned(s.to_string()); Self::try_from(cow_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": 16, "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_-841769499540836508_425_50
clm
snippet
// connector-service/backend/common_utils/src/id_type.rs impl crate::events::ApiEventMetric for ProfileAcquirerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::ProfileAcquirer { profile_acquirer_id: self.clone(), }) } } impl FromStr for ProfileAcquirerId { type Err = error_stack::Report<ValidationError>; fn from_str(s: &str) -> Result<Self, Self::Err> { let cow_string = Cow::Owned(s.to_string()); Self::try_from(cow_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": 16, "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_5683649008329316125_0_15
clm
snippet
// connector-service/backend/common_utils/src/macros.rs mod id_type { /// Defines an ID type. #[macro_export] macro_rules! id_type { ($type:ident, $doc:literal, $max_length:expr, $min_length:expr) => { #[doc = $doc] #[derive( Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize, utoipa::ToSchema, )] #[schema(value_type = String)] pub struct $type($crate::id_type::LengthId<$max_length, $min_length>); }; ($type:ident, $doc:literal) => { $crate::id_type!( $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": 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_5683649008329316125_0_30
clm
snippet
// connector-service/backend/common_utils/src/macros.rs mod id_type { /// Defines an ID type. #[macro_export] macro_rules! id_type { ($type:ident, $doc:literal, $max_length:expr, $min_length:expr) => { #[doc = $doc] #[derive( Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize, utoipa::ToSchema, )] #[schema(value_type = String)] pub struct $type($crate::id_type::LengthId<$max_length, $min_length>); }; ($type:ident, $doc:literal) => { $crate::id_type!( $type, $doc, { $crate::consts::MAX_ALLOWED_MERCHANT_REFERENCE_ID_LENGTH }, { $crate::consts::MIN_REQUIRED_MERCHANT_REFERENCE_ID_LENGTH } ); }; } /// Defines a Global Id type #[macro_export] macro_rules! global_id_type { ($type:ident, $doc:literal) => { #[doc = $doc] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct $type($crate::global_id::GlobalId);
{ "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_5683649008329316125_0_50
clm
snippet
// connector-service/backend/common_utils/src/macros.rs mod id_type { /// Defines an ID type. #[macro_export] macro_rules! id_type { ($type:ident, $doc:literal, $max_length:expr, $min_length:expr) => { #[doc = $doc] #[derive( Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize, utoipa::ToSchema, )] #[schema(value_type = String)] pub struct $type($crate::id_type::LengthId<$max_length, $min_length>); }; ($type:ident, $doc:literal) => { $crate::id_type!( $type, $doc, { $crate::consts::MAX_ALLOWED_MERCHANT_REFERENCE_ID_LENGTH }, { $crate::consts::MIN_REQUIRED_MERCHANT_REFERENCE_ID_LENGTH } ); }; } /// Defines a Global Id type #[macro_export] macro_rules! global_id_type { ($type:ident, $doc:literal) => { #[doc = $doc] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct $type($crate::global_id::GlobalId); }; } /// Implements common methods on the specified ID type. #[macro_export] macro_rules! impl_id_type_methods { ($type:ty, $field_name:literal) => { impl $type { /// Get the string representation of the ID type. pub fn get_string_repr(&self) -> &str { &self.0 .0 .0 } } }; } /// Implements the `Debug` trait on the specified ID type. #[macro_export] macro_rules! impl_debug_id_type { ($type:ty) => {
{ "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_5683649008329316125_25_15
clm
snippet
// connector-service/backend/common_utils/src/macros.rs ($type:ident, $doc:literal) => { #[doc = $doc] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct $type($crate::global_id::GlobalId); }; } /// Implements common methods on the specified ID type. #[macro_export] macro_rules! impl_id_type_methods { ($type:ty, $field_name:literal) => { impl $type { /// Get the string representation of the ID type. pub fn get_string_repr(&self) -> &str {
{ "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_5683649008329316125_25_30
clm
snippet
// connector-service/backend/common_utils/src/macros.rs ($type:ident, $doc:literal) => { #[doc = $doc] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct $type($crate::global_id::GlobalId); }; } /// Implements common methods on the specified ID type. #[macro_export] macro_rules! impl_id_type_methods { ($type:ty, $field_name:literal) => { impl $type { /// Get the string representation of the ID type. pub fn get_string_repr(&self) -> &str { &self.0 .0 .0 } } }; } /// Implements the `Debug` trait on the specified ID type. #[macro_export] macro_rules! impl_debug_id_type { ($type:ty) => { impl core::fmt::Debug for $type { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_tuple(stringify!($type)) .field(&self.0 .0 .0) .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": 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_5683649008329316125_25_50
clm
snippet
// connector-service/backend/common_utils/src/macros.rs ($type:ident, $doc:literal) => { #[doc = $doc] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct $type($crate::global_id::GlobalId); }; } /// Implements common methods on the specified ID type. #[macro_export] macro_rules! impl_id_type_methods { ($type:ty, $field_name:literal) => { impl $type { /// Get the string representation of the ID type. pub fn get_string_repr(&self) -> &str { &self.0 .0 .0 } } }; } /// Implements the `Debug` trait on the specified ID type. #[macro_export] macro_rules! impl_debug_id_type { ($type:ty) => { impl core::fmt::Debug for $type { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_tuple(stringify!($type)) .field(&self.0 .0 .0) .finish() } } }; } /// Implements the `TryFrom<Cow<'static, str>>` trait on the specified ID type. #[macro_export] macro_rules! impl_try_from_cow_str_id_type { ($type:ty, $field_name:literal) => { impl TryFrom<std::borrow::Cow<'static, str>> for $type { type Error = error_stack::Report<$crate::errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { use error_stack::ResultExt; let merchant_ref_id = $crate::id_type::LengthId::from(value).change_context( $crate::errors::ValidationError::IncorrectValueProvided { field_name: $field_name, }, )?;
{ "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_5683649008329316125_50_15
clm
snippet
// connector-service/backend/common_utils/src/macros.rs impl core::fmt::Debug for $type { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_tuple(stringify!($type)) .field(&self.0 .0 .0) .finish() } } }; } /// Implements the `TryFrom<Cow<'static, str>>` trait on the specified ID type. #[macro_export] macro_rules! impl_try_from_cow_str_id_type { ($type:ty, $field_name:literal) => { impl TryFrom<std::borrow::Cow<'static, str>> for $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": 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_5683649008329316125_50_30
clm
snippet
// connector-service/backend/common_utils/src/macros.rs impl core::fmt::Debug for $type { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_tuple(stringify!($type)) .field(&self.0 .0 .0) .finish() } } }; } /// Implements the `TryFrom<Cow<'static, str>>` trait on the specified ID type. #[macro_export] macro_rules! impl_try_from_cow_str_id_type { ($type:ty, $field_name:literal) => { impl TryFrom<std::borrow::Cow<'static, str>> for $type { type Error = error_stack::Report<$crate::errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { use error_stack::ResultExt; let merchant_ref_id = $crate::id_type::LengthId::from(value).change_context( $crate::errors::ValidationError::IncorrectValueProvided { field_name: $field_name, }, )?; Ok(Self(merchant_ref_id)) } } };
{ "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_5683649008329316125_50_50
clm
snippet
// connector-service/backend/common_utils/src/macros.rs impl core::fmt::Debug for $type { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_tuple(stringify!($type)) .field(&self.0 .0 .0) .finish() } } }; } /// Implements the `TryFrom<Cow<'static, str>>` trait on the specified ID type. #[macro_export] macro_rules! impl_try_from_cow_str_id_type { ($type:ty, $field_name:literal) => { impl TryFrom<std::borrow::Cow<'static, str>> for $type { type Error = error_stack::Report<$crate::errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { use error_stack::ResultExt; let merchant_ref_id = $crate::id_type::LengthId::from(value).change_context( $crate::errors::ValidationError::IncorrectValueProvided { field_name: $field_name, }, )?; Ok(Self(merchant_ref_id)) } } }; } /// Implements the `Default` trait on the specified ID type. #[macro_export] macro_rules! impl_default_id_type { ($type:ty, $prefix:literal) => { impl Default for $type { fn default() -> Self { Self($crate::generate_ref_id_with_default_length($prefix)) } } }; } /// Implements the `GenerateId` trait on the specified ID type. #[macro_export] macro_rules! impl_generate_id_id_type { ($type:ty, $prefix:literal) => { impl $crate::id_type::GenerateId for $type { fn generate() -> 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": 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_5683649008329316125_75_15
clm
snippet
// connector-service/backend/common_utils/src/macros.rs Ok(Self(merchant_ref_id)) } } }; } /// Implements the `Default` trait on the specified ID type. #[macro_export] macro_rules! impl_default_id_type { ($type:ty, $prefix:literal) => { impl Default for $type { fn default() -> Self { Self($crate::generate_ref_id_with_default_length($prefix)) }
{ "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_5683649008329316125_75_30
clm
snippet
// connector-service/backend/common_utils/src/macros.rs Ok(Self(merchant_ref_id)) } } }; } /// Implements the `Default` trait on the specified ID type. #[macro_export] macro_rules! impl_default_id_type { ($type:ty, $prefix:literal) => { impl Default for $type { fn default() -> Self { Self($crate::generate_ref_id_with_default_length($prefix)) } } }; } /// Implements the `GenerateId` trait on the specified ID type. #[macro_export] macro_rules! impl_generate_id_id_type { ($type:ty, $prefix:literal) => { impl $crate::id_type::GenerateId for $type { fn generate() -> Self { Self($crate::generate_ref_id_with_default_length($prefix)) } } }; }
{ "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_5683649008329316125_75_50
clm
snippet
// connector-service/backend/common_utils/src/macros.rs Ok(Self(merchant_ref_id)) } } }; } /// Implements the `Default` trait on the specified ID type. #[macro_export] macro_rules! impl_default_id_type { ($type:ty, $prefix:literal) => { impl Default for $type { fn default() -> Self { Self($crate::generate_ref_id_with_default_length($prefix)) } } }; } /// Implements the `GenerateId` trait on the specified ID type. #[macro_export] macro_rules! impl_generate_id_id_type { ($type:ty, $prefix:literal) => { impl $crate::id_type::GenerateId for $type { fn generate() -> Self { Self($crate::generate_ref_id_with_default_length($prefix)) } } }; } /// Implements the `SerializableSecret` trait on the specified ID type. #[macro_export] macro_rules! impl_serializable_secret_id_type { ($type:ty) => { impl hyperswitch_masking::SerializableSecret for $type {} }; } } /// Collects names of all optional fields that are `None`. /// This is typically useful for constructing error messages including a list of all missing fields. #[macro_export] macro_rules! collect_missing_value_keys { [$(($key:literal, $option:expr)),+] => { { let mut keys: Vec<&'static str> = Vec::new(); $( if $option.is_none() { keys.push($key);
{ "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_5683649008329316125_100_15
clm
snippet
// connector-service/backend/common_utils/src/macros.rs Self($crate::generate_ref_id_with_default_length($prefix)) } } }; } /// Implements the `SerializableSecret` trait on the specified ID type. #[macro_export] macro_rules! impl_serializable_secret_id_type { ($type:ty) => { impl hyperswitch_masking::SerializableSecret for $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": 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_5683649008329316125_100_30
clm
snippet
// connector-service/backend/common_utils/src/macros.rs Self($crate::generate_ref_id_with_default_length($prefix)) } } }; } /// Implements the `SerializableSecret` trait on the specified ID type. #[macro_export] macro_rules! impl_serializable_secret_id_type { ($type:ty) => { impl hyperswitch_masking::SerializableSecret for $type {} }; } } /// Collects names of all optional fields that are `None`. /// This is typically useful for constructing error messages including a list of all missing fields. #[macro_export] macro_rules! collect_missing_value_keys { [$(($key:literal, $option:expr)),+] => { { let mut keys: Vec<&'static str> = Vec::new(); $( if $option.is_none() { keys.push($key); } )* 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": 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_5683649008329316125_100_50
clm
snippet
// connector-service/backend/common_utils/src/macros.rs Self($crate::generate_ref_id_with_default_length($prefix)) } } }; } /// Implements the `SerializableSecret` trait on the specified ID type. #[macro_export] macro_rules! impl_serializable_secret_id_type { ($type:ty) => { impl hyperswitch_masking::SerializableSecret for $type {} }; } } /// Collects names of all optional fields that are `None`. /// This is typically useful for constructing error messages including a list of all missing fields. #[macro_export] macro_rules! collect_missing_value_keys { [$(($key:literal, $option:expr)),+] => { { let mut keys: Vec<&'static str> = Vec::new(); $( if $option.is_none() { keys.push($key); } )* 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": 31, "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_8833799470967369792_0_15
clm
snippet
// connector-service/backend/common_utils/src/crypto.rs //! Utilities for cryptographic algorithms use std::ops::Deref; use error_stack::ResultExt; use hyperswitch_masking::{ExposeInterface, Secret}; use md5; use ring::{ aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey}, hmac, }; use crate::{ errors::{self, CustomResult}, pii::{self, EncryptionStrategy}, };
{ "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_8833799470967369792_0_30
clm
snippet
// connector-service/backend/common_utils/src/crypto.rs //! Utilities for cryptographic algorithms use std::ops::Deref; use error_stack::ResultExt; use hyperswitch_masking::{ExposeInterface, Secret}; use md5; use ring::{ aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey}, hmac, }; use crate::{ errors::{self, CustomResult}, pii::{self, EncryptionStrategy}, }; #[derive(Clone, Debug)] struct NonceSequence(u128); impl NonceSequence { /// Byte index at which sequence number starts in a 16-byte (128-bit) sequence. /// This byte index considers the big endian order used while encoding and decoding the nonce /// to/from a 128-bit unsigned integer. const SEQUENCE_NUMBER_START_INDEX: usize = 4; /// Generate a random nonce sequence. fn new() -> Result<Self, ring::error::Unspecified> { use ring::rand::{SecureRandom, SystemRandom}; let rng = SystemRandom::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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_8833799470967369792_0_50
clm
snippet
// connector-service/backend/common_utils/src/crypto.rs //! Utilities for cryptographic algorithms use std::ops::Deref; use error_stack::ResultExt; use hyperswitch_masking::{ExposeInterface, Secret}; use md5; use ring::{ aead::{self, BoundKey, OpeningKey, SealingKey, UnboundKey}, hmac, }; use crate::{ errors::{self, CustomResult}, pii::{self, EncryptionStrategy}, }; #[derive(Clone, Debug)] struct NonceSequence(u128); impl NonceSequence { /// Byte index at which sequence number starts in a 16-byte (128-bit) sequence. /// This byte index considers the big endian order used while encoding and decoding the nonce /// to/from a 128-bit unsigned integer. const SEQUENCE_NUMBER_START_INDEX: usize = 4; /// Generate a random nonce sequence. fn new() -> Result<Self, ring::error::Unspecified> { use ring::rand::{SecureRandom, SystemRandom}; let rng = SystemRandom::new(); // 96-bit sequence number, stored in a 128-bit unsigned integer in big-endian order let mut sequence_number = [0_u8; 128 / 8]; rng.fill(&mut sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..])?; let sequence_number = u128::from_be_bytes(sequence_number); Ok(Self(sequence_number)) } /// Returns the current nonce value as bytes. fn current(&self) -> [u8; aead::NONCE_LEN] { let mut nonce = [0_u8; aead::NONCE_LEN]; nonce.copy_from_slice(&self.0.to_be_bytes()[Self::SEQUENCE_NUMBER_START_INDEX..]); nonce } /// Constructs a nonce sequence from bytes fn from_bytes(bytes: [u8; aead::NONCE_LEN]) -> Self { let mut sequence_number = [0_u8; 128 / 8]; sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..].copy_from_slice(&bytes);
{ "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_8833799470967369792_25_15
clm
snippet
// connector-service/backend/common_utils/src/crypto.rs /// Generate a random nonce sequence. fn new() -> Result<Self, ring::error::Unspecified> { use ring::rand::{SecureRandom, SystemRandom}; let rng = SystemRandom::new(); // 96-bit sequence number, stored in a 128-bit unsigned integer in big-endian order let mut sequence_number = [0_u8; 128 / 8]; rng.fill(&mut sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..])?; let sequence_number = u128::from_be_bytes(sequence_number); Ok(Self(sequence_number)) } /// Returns the current nonce value as bytes.
{ "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_8833799470967369792_25_30
clm
snippet
// connector-service/backend/common_utils/src/crypto.rs /// Generate a random nonce sequence. fn new() -> Result<Self, ring::error::Unspecified> { use ring::rand::{SecureRandom, SystemRandom}; let rng = SystemRandom::new(); // 96-bit sequence number, stored in a 128-bit unsigned integer in big-endian order let mut sequence_number = [0_u8; 128 / 8]; rng.fill(&mut sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..])?; let sequence_number = u128::from_be_bytes(sequence_number); Ok(Self(sequence_number)) } /// Returns the current nonce value as bytes. fn current(&self) -> [u8; aead::NONCE_LEN] { let mut nonce = [0_u8; aead::NONCE_LEN]; nonce.copy_from_slice(&self.0.to_be_bytes()[Self::SEQUENCE_NUMBER_START_INDEX..]); nonce } /// Constructs a nonce sequence from bytes fn from_bytes(bytes: [u8; aead::NONCE_LEN]) -> Self { let mut sequence_number = [0_u8; 128 / 8]; sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..].copy_from_slice(&bytes); let sequence_number = u128::from_be_bytes(sequence_number); Self(sequence_number) } }
{ "chunk": null, "crate": "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_8833799470967369792_25_50
clm
snippet
// connector-service/backend/common_utils/src/crypto.rs /// Generate a random nonce sequence. fn new() -> Result<Self, ring::error::Unspecified> { use ring::rand::{SecureRandom, SystemRandom}; let rng = SystemRandom::new(); // 96-bit sequence number, stored in a 128-bit unsigned integer in big-endian order let mut sequence_number = [0_u8; 128 / 8]; rng.fill(&mut sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..])?; let sequence_number = u128::from_be_bytes(sequence_number); Ok(Self(sequence_number)) } /// Returns the current nonce value as bytes. fn current(&self) -> [u8; aead::NONCE_LEN] { let mut nonce = [0_u8; aead::NONCE_LEN]; nonce.copy_from_slice(&self.0.to_be_bytes()[Self::SEQUENCE_NUMBER_START_INDEX..]); nonce } /// Constructs a nonce sequence from bytes fn from_bytes(bytes: [u8; aead::NONCE_LEN]) -> Self { let mut sequence_number = [0_u8; 128 / 8]; sequence_number[Self::SEQUENCE_NUMBER_START_INDEX..].copy_from_slice(&bytes); let sequence_number = u128::from_be_bytes(sequence_number); Self(sequence_number) } } impl aead::NonceSequence for NonceSequence { fn advance(&mut self) -> Result<aead::Nonce, ring::error::Unspecified> { let mut nonce = [0_u8; aead::NONCE_LEN]; nonce.copy_from_slice(&self.0.to_be_bytes()[Self::SEQUENCE_NUMBER_START_INDEX..]); // Increment sequence number self.0 = self.0.wrapping_add(1); // Return previous sequence number as bytes Ok(aead::Nonce::assume_unique_for_key(nonce)) } } /// Trait for cryptographically signing messages pub trait SignMessage { /// Takes in a secret and a message and returns the calculated signature as bytes fn sign_message( &self, _secret: &[u8], _msg: &[u8],
{ "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_8833799470967369792_50_15
clm
snippet
// connector-service/backend/common_utils/src/crypto.rs let sequence_number = u128::from_be_bytes(sequence_number); Self(sequence_number) } } impl aead::NonceSequence for NonceSequence { fn advance(&mut self) -> Result<aead::Nonce, ring::error::Unspecified> { let mut nonce = [0_u8; aead::NONCE_LEN]; nonce.copy_from_slice(&self.0.to_be_bytes()[Self::SEQUENCE_NUMBER_START_INDEX..]); // Increment sequence number self.0 = self.0.wrapping_add(1); // Return previous sequence number as bytes Ok(aead::Nonce::assume_unique_for_key(nonce))
{ "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 }