id
stringlengths
20
153
type
stringclasses
1 value
granularity
stringclasses
14 values
content
stringlengths
16
84.3k
metadata
dict
connector-service_snippet_2048526090272796786_50_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs let writer = KafkaWriterBuilder::new() .brokers(config.brokers.clone()) .topic(config.topic.clone()) .build() .map_err(|e| { error_stack::Report::new(EventPublisherError::KafkaWriterInitializationFailed) .attach_printable(format!("KafkaWriter build failed: {e}")) .attach_printable(format!( "Brokers: {:?}, Topic: {}", config.brokers, config.topic )) })?; tracing::info!("EventPublisher created successfully"); Ok(Self { writer: Arc::new(writer), config: config.clone(), }) } /// Publishes a single event to Kafka with metadata as headers. pub fn publish_event( &self, event: serde_json::Value, topic: &str, partition_key_field: &str, ) -> CustomResult<(), EventPublisherError> { let metadata = OwnedHeaders::new(); self.publish_event_with_metadata(event, topic, partition_key_field, metadata) } /// Publishes a single event to Kafka with custom metadata. pub fn publish_event_with_metadata( &self, event: serde_json::Value, topic: &str, partition_key_field: &str, metadata: OwnedHeaders, ) -> CustomResult<(), EventPublisherError> { tracing::debug!( topic = %topic, partition_key_field = %partition_key_field, "Starting event publication to Kafka" ); let mut headers = metadata; let key = if let Some(partition_key_value) =
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 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_2048526090272796786_75_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs event: serde_json::Value, topic: &str, partition_key_field: &str, ) -> CustomResult<(), EventPublisherError> { let metadata = OwnedHeaders::new(); self.publish_event_with_metadata(event, topic, partition_key_field, metadata) } /// Publishes a single event to Kafka with custom metadata. pub fn publish_event_with_metadata( &self, event: serde_json::Value, topic: &str, partition_key_field: &str, metadata: OwnedHeaders,
{ "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_2048526090272796786_75_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs event: serde_json::Value, topic: &str, partition_key_field: &str, ) -> CustomResult<(), EventPublisherError> { let metadata = OwnedHeaders::new(); self.publish_event_with_metadata(event, topic, partition_key_field, metadata) } /// Publishes a single event to Kafka with custom metadata. pub fn publish_event_with_metadata( &self, event: serde_json::Value, topic: &str, partition_key_field: &str, metadata: OwnedHeaders, ) -> CustomResult<(), EventPublisherError> { tracing::debug!( topic = %topic, partition_key_field = %partition_key_field, "Starting event publication to Kafka" ); let mut headers = metadata; let key = if let Some(partition_key_value) = event.get(partition_key_field).and_then(|v| v.as_str()) { headers = headers.insert(Header { key: PARTITION_KEY_METADATA, value: Some(partition_key_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": 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_2048526090272796786_75_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs event: serde_json::Value, topic: &str, partition_key_field: &str, ) -> CustomResult<(), EventPublisherError> { let metadata = OwnedHeaders::new(); self.publish_event_with_metadata(event, topic, partition_key_field, metadata) } /// Publishes a single event to Kafka with custom metadata. pub fn publish_event_with_metadata( &self, event: serde_json::Value, topic: &str, partition_key_field: &str, metadata: OwnedHeaders, ) -> CustomResult<(), EventPublisherError> { tracing::debug!( topic = %topic, partition_key_field = %partition_key_field, "Starting event publication to Kafka" ); let mut headers = metadata; let key = if let Some(partition_key_value) = event.get(partition_key_field).and_then(|v| v.as_str()) { headers = headers.insert(Header { key: PARTITION_KEY_METADATA, value: Some(partition_key_value.as_bytes()), }); Some(partition_key_value) } else { tracing::warn!( partition_key_field = %partition_key_field, "Partition key field not found in event, message will be published without key" ); None }; let event_bytes = serde_json::to_vec(&event).map_err(|e| { error_stack::Report::new(EventPublisherError::EventSerializationFailed) .attach_printable(format!("Failed to serialize Event to JSON bytes: {e}")) })?; self.writer .publish_event(&self.config.topic, key, &event_bytes, Some(headers)) .map_err(|e| { let event_json = serde_json::to_string(&event).unwrap_or_default(); error_stack::Report::new(EventPublisherError::EventPublishFailed)
{ "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_2048526090272796786_100_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs event.get(partition_key_field).and_then(|v| v.as_str()) { headers = headers.insert(Header { key: PARTITION_KEY_METADATA, value: Some(partition_key_value.as_bytes()), }); Some(partition_key_value) } else { tracing::warn!( partition_key_field = %partition_key_field, "Partition key field not found in event, message will be published without key" ); None };
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 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_2048526090272796786_100_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs event.get(partition_key_field).and_then(|v| v.as_str()) { headers = headers.insert(Header { key: PARTITION_KEY_METADATA, value: Some(partition_key_value.as_bytes()), }); Some(partition_key_value) } else { tracing::warn!( partition_key_field = %partition_key_field, "Partition key field not found in event, message will be published without key" ); None }; let event_bytes = serde_json::to_vec(&event).map_err(|e| { error_stack::Report::new(EventPublisherError::EventSerializationFailed) .attach_printable(format!("Failed to serialize Event to JSON bytes: {e}")) })?; self.writer .publish_event(&self.config.topic, key, &event_bytes, Some(headers)) .map_err(|e| { let event_json = serde_json::to_string(&event).unwrap_or_default(); error_stack::Report::new(EventPublisherError::EventPublishFailed) .attach_printable(format!("Kafka publish failed: {e}")) .attach_printable(format!( "Topic: {}, Event size: {} bytes", self.config.topic, event_bytes.len()
{ "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_2048526090272796786_100_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs event.get(partition_key_field).and_then(|v| v.as_str()) { headers = headers.insert(Header { key: PARTITION_KEY_METADATA, value: Some(partition_key_value.as_bytes()), }); Some(partition_key_value) } else { tracing::warn!( partition_key_field = %partition_key_field, "Partition key field not found in event, message will be published without key" ); None }; let event_bytes = serde_json::to_vec(&event).map_err(|e| { error_stack::Report::new(EventPublisherError::EventSerializationFailed) .attach_printable(format!("Failed to serialize Event to JSON bytes: {e}")) })?; self.writer .publish_event(&self.config.topic, key, &event_bytes, Some(headers)) .map_err(|e| { let event_json = serde_json::to_string(&event).unwrap_or_default(); error_stack::Report::new(EventPublisherError::EventPublishFailed) .attach_printable(format!("Kafka publish failed: {e}")) .attach_printable(format!( "Topic: {}, Event size: {} bytes", self.config.topic, event_bytes.len() )) .attach_printable(format!("Failed event: {event_json}")) })?; let event_json = serde_json::to_string(&event).unwrap_or_default(); tracing::info!( full_event = %event_json, "Event successfully published to Kafka" ); Ok(()) } pub fn emit_event_with_config( &self, base_event: Event, config: &EventConfig, ) -> CustomResult<(), EventPublisherError> { let metadata = self.build_kafka_metadata(&base_event); let processed_event = self.process_event(&base_event)?;
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 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_2048526090272796786_125_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs .attach_printable(format!("Kafka publish failed: {e}")) .attach_printable(format!( "Topic: {}, Event size: {} bytes", self.config.topic, event_bytes.len() )) .attach_printable(format!("Failed event: {event_json}")) })?; let event_json = serde_json::to_string(&event).unwrap_or_default(); tracing::info!( full_event = %event_json, "Event successfully published 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": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2048526090272796786_125_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs .attach_printable(format!("Kafka publish failed: {e}")) .attach_printable(format!( "Topic: {}, Event size: {} bytes", self.config.topic, event_bytes.len() )) .attach_printable(format!("Failed event: {event_json}")) })?; let event_json = serde_json::to_string(&event).unwrap_or_default(); tracing::info!( full_event = %event_json, "Event successfully published to Kafka" ); Ok(()) } pub fn emit_event_with_config( &self, base_event: Event, config: &EventConfig, ) -> CustomResult<(), EventPublisherError> { let metadata = self.build_kafka_metadata(&base_event); let processed_event = self.process_event(&base_event)?; self.publish_event_with_metadata( processed_event, &config.topic, &config.partition_key_field,
{ "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_2048526090272796786_125_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs .attach_printable(format!("Kafka publish failed: {e}")) .attach_printable(format!( "Topic: {}, Event size: {} bytes", self.config.topic, event_bytes.len() )) .attach_printable(format!("Failed event: {event_json}")) })?; let event_json = serde_json::to_string(&event).unwrap_or_default(); tracing::info!( full_event = %event_json, "Event successfully published to Kafka" ); Ok(()) } pub fn emit_event_with_config( &self, base_event: Event, config: &EventConfig, ) -> CustomResult<(), EventPublisherError> { let metadata = self.build_kafka_metadata(&base_event); let processed_event = self.process_event(&base_event)?; self.publish_event_with_metadata( processed_event, &config.topic, &config.partition_key_field, metadata, ) } fn build_kafka_metadata(&self, event: &Event) -> OwnedHeaders { let mut headers = OwnedHeaders::new(); // Add lineage headers from Event.lineage_ids for (key, value) in event.lineage_ids.inner() { headers = headers.insert(Header { key: &key, value: Some(value.as_bytes()), }); } let ref_id_option = event .additional_fields .get("reference_id") .and_then(|ref_id_value| ref_id_value.inner().as_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": 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_2048526090272796786_150_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs self.publish_event_with_metadata( processed_event, &config.topic, &config.partition_key_field, metadata, ) } fn build_kafka_metadata(&self, event: &Event) -> OwnedHeaders { let mut headers = OwnedHeaders::new(); // Add lineage headers from Event.lineage_ids for (key, value) in event.lineage_ids.inner() { headers = headers.insert(Header {
{ "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_2048526090272796786_150_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs self.publish_event_with_metadata( processed_event, &config.topic, &config.partition_key_field, metadata, ) } fn build_kafka_metadata(&self, event: &Event) -> OwnedHeaders { let mut headers = OwnedHeaders::new(); // Add lineage headers from Event.lineage_ids for (key, value) in event.lineage_ids.inner() { headers = headers.insert(Header { key: &key, value: Some(value.as_bytes()), }); } let ref_id_option = event .additional_fields .get("reference_id") .and_then(|ref_id_value| ref_id_value.inner().as_str()); // Add reference_id from Event.additional_fields if let Some(ref_id_str) = ref_id_option { headers = headers.insert(Header { key: "reference_id", value: Some(ref_id_str.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": 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_2048526090272796786_150_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs self.publish_event_with_metadata( processed_event, &config.topic, &config.partition_key_field, metadata, ) } fn build_kafka_metadata(&self, event: &Event) -> OwnedHeaders { let mut headers = OwnedHeaders::new(); // Add lineage headers from Event.lineage_ids for (key, value) in event.lineage_ids.inner() { headers = headers.insert(Header { key: &key, value: Some(value.as_bytes()), }); } let ref_id_option = event .additional_fields .get("reference_id") .and_then(|ref_id_value| ref_id_value.inner().as_str()); // Add reference_id from Event.additional_fields if let Some(ref_id_str) = ref_id_option { headers = headers.insert(Header { key: "reference_id", value: Some(ref_id_str.as_bytes()), }); } headers } fn process_event(&self, event: &Event) -> CustomResult<serde_json::Value, EventPublisherError> { let mut result = event.masked_serialize().map_err(|e| { error_stack::Report::new(EventPublisherError::EventSerializationFailed) .attach_printable(format!("Event masked serialization failed: {e}")) })?; // Process transformations for (target_path, source_field) in &self.config.transformations { if let Some(value) = result.get(source_field).cloned() { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path,
{ "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_2048526090272796786_175_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs // Add reference_id from Event.additional_fields if let Some(ref_id_str) = ref_id_option { headers = headers.insert(Header { key: "reference_id", value: Some(ref_id_str.as_bytes()), }); } headers } fn process_event(&self, event: &Event) -> CustomResult<serde_json::Value, EventPublisherError> { let mut result = event.masked_serialize().map_err(|e| { error_stack::Report::new(EventPublisherError::EventSerializationFailed) .attach_printable(format!("Event masked serialization failed: {e}"))
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 175, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2048526090272796786_175_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs // Add reference_id from Event.additional_fields if let Some(ref_id_str) = ref_id_option { headers = headers.insert(Header { key: "reference_id", value: Some(ref_id_str.as_bytes()), }); } headers } fn process_event(&self, event: &Event) -> CustomResult<serde_json::Value, EventPublisherError> { let mut result = event.masked_serialize().map_err(|e| { error_stack::Report::new(EventPublisherError::EventSerializationFailed) .attach_printable(format!("Event masked serialization failed: {e}")) })?; // Process transformations for (target_path, source_field) in &self.config.transformations { if let Some(value) = result.get(source_field).cloned() { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, source_field = %source_field, error = %e, "Failed to set transformation, continuing with event processing" );
{ "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_2048526090272796786_175_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs // Add reference_id from Event.additional_fields if let Some(ref_id_str) = ref_id_option { headers = headers.insert(Header { key: "reference_id", value: Some(ref_id_str.as_bytes()), }); } headers } fn process_event(&self, event: &Event) -> CustomResult<serde_json::Value, EventPublisherError> { let mut result = event.masked_serialize().map_err(|e| { error_stack::Report::new(EventPublisherError::EventSerializationFailed) .attach_printable(format!("Event masked serialization failed: {e}")) })?; // Process transformations for (target_path, source_field) in &self.config.transformations { if let Some(value) = result.get(source_field).cloned() { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, source_field = %source_field, error = %e, "Failed to set transformation, continuing with event processing" ); } } } // Process static values - log warnings but continue processing for (target_path, static_value) in &self.config.static_values { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); let value = serde_json::json!(static_value); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, static_value = %static_value, error = %e, "Failed to set static value, continuing with event processing" ); } }
{ "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_2048526090272796786_200_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs normalized_path = %normalized_path, source_field = %source_field, error = %e, "Failed to set transformation, continuing with event processing" ); } } } // Process static values - log warnings but continue processing for (target_path, static_value) in &self.config.static_values { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); let value = serde_json::json!(static_value); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) {
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 200, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2048526090272796786_200_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs normalized_path = %normalized_path, source_field = %source_field, error = %e, "Failed to set transformation, continuing with event processing" ); } } } // Process static values - log warnings but continue processing for (target_path, static_value) in &self.config.static_values { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); let value = serde_json::json!(static_value); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, static_value = %static_value, error = %e, "Failed to set static value, continuing with event processing" ); } } // Process extraction for (target_path, extraction_path) in &self.config.extractions { if let Some(value) = self.extract_from_request(&result, extraction_path) { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", ".");
{ "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_2048526090272796786_200_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs normalized_path = %normalized_path, source_field = %source_field, error = %e, "Failed to set transformation, continuing with event processing" ); } } } // Process static values - log warnings but continue processing for (target_path, static_value) in &self.config.static_values { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); let value = serde_json::json!(static_value); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, static_value = %static_value, error = %e, "Failed to set static value, continuing with event processing" ); } } // Process extraction for (target_path, extraction_path) in &self.config.extractions { if let Some(value) = self.extract_from_request(&result, extraction_path) { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, extraction_path = %extraction_path, error = %e, "Failed to set extraction, continuing with event processing" ); } } } Ok(result) } fn extract_from_request( &self, event_value: &serde_json::Value, extraction_path: &str, ) -> Option<serde_json::Value> {
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 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_2048526090272796786_225_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs // Process extraction for (target_path, extraction_path) in &self.config.extractions { if let Some(value) = self.extract_from_request(&result, extraction_path) { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, extraction_path = %extraction_path, error = %e, "Failed to set extraction, continuing with event processing" ); } }
{ "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_2048526090272796786_225_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs // Process extraction for (target_path, extraction_path) in &self.config.extractions { if let Some(value) = self.extract_from_request(&result, extraction_path) { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, extraction_path = %extraction_path, error = %e, "Failed to set extraction, continuing with event processing" ); } } } Ok(result) } fn extract_from_request( &self, event_value: &serde_json::Value, extraction_path: &str, ) -> Option<serde_json::Value> { let mut path_parts = extraction_path.split('.'); let first_part = path_parts.next()?; let source = match first_part {
{ "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_2048526090272796786_225_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs // Process extraction for (target_path, extraction_path) in &self.config.extractions { if let Some(value) = self.extract_from_request(&result, extraction_path) { // Replace _DOT_ and _dot_ with . to support nested keys in environment variables let normalized_path = target_path.replace("_DOT_", ".").replace("_dot_", "."); if let Err(e) = self.set_nested_value(&mut result, &normalized_path, value) { tracing::warn!( target_path = %target_path, normalized_path = %normalized_path, extraction_path = %extraction_path, error = %e, "Failed to set extraction, continuing with event processing" ); } } } Ok(result) } fn extract_from_request( &self, event_value: &serde_json::Value, extraction_path: &str, ) -> Option<serde_json::Value> { let mut path_parts = extraction_path.split('.'); let first_part = path_parts.next()?; let source = match first_part { "req" => event_value.get("request_data")?.clone(), _ => return None, }; let mut current = &source; for part in path_parts { current = current.get(part)?; } Some(current.clone()) } fn set_nested_value( &self, target: &mut serde_json::Value, path: &str, value: serde_json::Value, ) -> CustomResult<(), EventPublisherError> { let path_parts: Vec<&str> = path.split('.').filter(|s| !s.is_empty()).collect();
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 50, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 225, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2048526090272796786_250_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs let mut path_parts = extraction_path.split('.'); let first_part = path_parts.next()?; let source = match first_part { "req" => event_value.get("request_data")?.clone(), _ => return None, }; let mut current = &source; for part in path_parts { current = current.get(part)?; } Some(current.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": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2048526090272796786_250_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs let mut path_parts = extraction_path.split('.'); let first_part = path_parts.next()?; let source = match first_part { "req" => event_value.get("request_data")?.clone(), _ => return None, }; let mut current = &source; for part in path_parts { current = current.get(part)?; } Some(current.clone()) } fn set_nested_value( &self, target: &mut serde_json::Value, path: &str, value: serde_json::Value, ) -> CustomResult<(), EventPublisherError> { let path_parts: Vec<&str> = path.split('.').filter(|s| !s.is_empty()).collect(); if path_parts.is_empty() { return Err(error_stack::Report::new(EventPublisherError::InvalidPath { path: path.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": 250, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2048526090272796786_250_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs let mut path_parts = extraction_path.split('.'); let first_part = path_parts.next()?; let source = match first_part { "req" => event_value.get("request_data")?.clone(), _ => return None, }; let mut current = &source; for part in path_parts { current = current.get(part)?; } Some(current.clone()) } fn set_nested_value( &self, target: &mut serde_json::Value, path: &str, value: serde_json::Value, ) -> CustomResult<(), EventPublisherError> { let path_parts: Vec<&str> = path.split('.').filter(|s| !s.is_empty()).collect(); if path_parts.is_empty() { return Err(error_stack::Report::new(EventPublisherError::InvalidPath { path: path.to_string(), })); } if path_parts.len() == 1 { if let Some(key) = path_parts.first() { target[*key] = value; return Ok(()); } } let result = path_parts.iter().enumerate().try_fold( target, |current, (index, &part)| -> CustomResult<&mut serde_json::Value, EventPublisherError> { if index == path_parts.len() - 1 { current[part] = value.clone(); Ok(current) } else { if !current[part].is_object() { current[part] = serde_json::json!({}); }
{ "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_2048526090272796786_275_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs if path_parts.is_empty() { return Err(error_stack::Report::new(EventPublisherError::InvalidPath { path: path.to_string(), })); } if path_parts.len() == 1 { if let Some(key) = path_parts.first() { target[*key] = value; return Ok(()); } } let result = path_parts.iter().enumerate().try_fold( target,
{ "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_2048526090272796786_275_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs if path_parts.is_empty() { return Err(error_stack::Report::new(EventPublisherError::InvalidPath { path: path.to_string(), })); } if path_parts.len() == 1 { if let Some(key) = path_parts.first() { target[*key] = value; return Ok(()); } } let result = path_parts.iter().enumerate().try_fold( target, |current, (index, &part)| -> CustomResult<&mut serde_json::Value, EventPublisherError> { if index == path_parts.len() - 1 { current[part] = value.clone(); Ok(current) } else { if !current[part].is_object() { current[part] = serde_json::json!({}); } current.get_mut(part).ok_or_else(|| { error_stack::Report::new(EventPublisherError::InvalidPath { path: format!("{path}.{part}"), }) })
{ "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_2048526090272796786_275_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs if path_parts.is_empty() { return Err(error_stack::Report::new(EventPublisherError::InvalidPath { path: path.to_string(), })); } if path_parts.len() == 1 { if let Some(key) = path_parts.first() { target[*key] = value; return Ok(()); } } let result = path_parts.iter().enumerate().try_fold( target, |current, (index, &part)| -> CustomResult<&mut serde_json::Value, EventPublisherError> { if index == path_parts.len() - 1 { current[part] = value.clone(); Ok(current) } else { if !current[part].is_object() { current[part] = serde_json::json!({}); } current.get_mut(part).ok_or_else(|| { error_stack::Report::new(EventPublisherError::InvalidPath { path: format!("{path}.{part}"), }) }) } }, ); result.map(|_| ()) } } /// Initialize the global EventPublisher with the given configuration pub fn init_event_publisher(config: &EventConfig) -> CustomResult<(), EventPublisherError> { tracing::info!( enabled = config.enabled, "Initializing global EventPublisher" ); let publisher = EventPublisher::new(config)?; EVENT_PUBLISHER.set(publisher).map_err(|failed_publisher| { error_stack::Report::new(EventPublisherError::AlreadyInitialized) .attach_printable("EventPublisher was already initialized")
{ "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_2048526090272796786_300_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs current.get_mut(part).ok_or_else(|| { error_stack::Report::new(EventPublisherError::InvalidPath { path: format!("{path}.{part}"), }) }) } }, ); result.map(|_| ()) } } /// Initialize the global EventPublisher with the given configuration pub fn init_event_publisher(config: &EventConfig) -> CustomResult<(), EventPublisherError> {
{ "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_2048526090272796786_300_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs current.get_mut(part).ok_or_else(|| { error_stack::Report::new(EventPublisherError::InvalidPath { path: format!("{path}.{part}"), }) }) } }, ); result.map(|_| ()) } } /// Initialize the global EventPublisher with the given configuration pub fn init_event_publisher(config: &EventConfig) -> CustomResult<(), EventPublisherError> { tracing::info!( enabled = config.enabled, "Initializing global EventPublisher" ); let publisher = EventPublisher::new(config)?; EVENT_PUBLISHER.set(publisher).map_err(|failed_publisher| { error_stack::Report::new(EventPublisherError::AlreadyInitialized) .attach_printable("EventPublisher was already initialized") .attach_printable(format!( "Existing config: brokers={:?}, topic={}", failed_publisher.config.brokers, failed_publisher.config.topic )) .attach_printable(format!(
{ "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_2048526090272796786_300_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs current.get_mut(part).ok_or_else(|| { error_stack::Report::new(EventPublisherError::InvalidPath { path: format!("{path}.{part}"), }) }) } }, ); result.map(|_| ()) } } /// Initialize the global EventPublisher with the given configuration pub fn init_event_publisher(config: &EventConfig) -> CustomResult<(), EventPublisherError> { tracing::info!( enabled = config.enabled, "Initializing global EventPublisher" ); let publisher = EventPublisher::new(config)?; EVENT_PUBLISHER.set(publisher).map_err(|failed_publisher| { error_stack::Report::new(EventPublisherError::AlreadyInitialized) .attach_printable("EventPublisher was already initialized") .attach_printable(format!( "Existing config: brokers={:?}, topic={}", failed_publisher.config.brokers, failed_publisher.config.topic )) .attach_printable(format!( "New config: brokers={:?}, topic={}", config.brokers, config.topic )) })?; tracing::info!("Global EventPublisher initialized successfully"); Ok(()) } /// Get or initialize the global EventPublisher fn get_event_publisher( config: &EventConfig, ) -> CustomResult<&'static EventPublisher, EventPublisherError> { EVENT_PUBLISHER.get_or_try_init(|| EventPublisher::new(config)) } /// Standalone function to emit events using the global EventPublisher pub fn emit_event_with_config(event: Event, config: &EventConfig) { if !config.enabled { tracing::info!("Event publishing disabled");
{ "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_2048526090272796786_325_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs .attach_printable(format!( "Existing config: brokers={:?}, topic={}", failed_publisher.config.brokers, failed_publisher.config.topic )) .attach_printable(format!( "New config: brokers={:?}, topic={}", config.brokers, config.topic )) })?; tracing::info!("Global EventPublisher initialized successfully"); Ok(()) } /// Get or initialize the global EventPublisher
{ "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_2048526090272796786_325_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs .attach_printable(format!( "Existing config: brokers={:?}, topic={}", failed_publisher.config.brokers, failed_publisher.config.topic )) .attach_printable(format!( "New config: brokers={:?}, topic={}", config.brokers, config.topic )) })?; tracing::info!("Global EventPublisher initialized successfully"); Ok(()) } /// Get or initialize the global EventPublisher fn get_event_publisher( config: &EventConfig, ) -> CustomResult<&'static EventPublisher, EventPublisherError> { EVENT_PUBLISHER.get_or_try_init(|| EventPublisher::new(config)) } /// Standalone function to emit events using the global EventPublisher pub fn emit_event_with_config(event: Event, config: &EventConfig) { if !config.enabled { tracing::info!("Event publishing disabled"); return; } // just log the error if publishing fails let _ = get_event_publisher(config)
{ "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_2048526090272796786_325_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs .attach_printable(format!( "Existing config: brokers={:?}, topic={}", failed_publisher.config.brokers, failed_publisher.config.topic )) .attach_printable(format!( "New config: brokers={:?}, topic={}", config.brokers, config.topic )) })?; tracing::info!("Global EventPublisher initialized successfully"); Ok(()) } /// Get or initialize the global EventPublisher fn get_event_publisher( config: &EventConfig, ) -> CustomResult<&'static EventPublisher, EventPublisherError> { EVENT_PUBLISHER.get_or_try_init(|| EventPublisher::new(config)) } /// Standalone function to emit events using the global EventPublisher pub fn emit_event_with_config(event: Event, config: &EventConfig) { if !config.enabled { tracing::info!("Event publishing disabled"); return; } // just log the error if publishing fails let _ = get_event_publisher(config) .and_then(|publisher| publisher.emit_event_with_config(event, config)) .inspect_err(|e| { tracing::error!(error = ?e, "Failed to emit event"); }); }
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 35, "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_2048526090272796786_350_15
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs return; } // just log the error if publishing fails let _ = get_event_publisher(config) .and_then(|publisher| publisher.emit_event_with_config(event, config)) .inspect_err(|e| { tracing::error!(error = ?e, "Failed to emit event"); }); }
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 10, "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_2048526090272796786_350_30
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs return; } // just log the error if publishing fails let _ = get_event_publisher(config) .and_then(|publisher| publisher.emit_event_with_config(event, config)) .inspect_err(|e| { tracing::error!(error = ?e, "Failed to emit event"); }); }
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 10, "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_2048526090272796786_350_50
clm
snippet
// connector-service/backend/common_utils/src/event_publisher.rs return; } // just log the error if publishing fails let _ = get_event_publisher(config) .and_then(|publisher| publisher.emit_event_with_config(event, config)) .inspect_err(|e| { tracing::error!(error = ?e, "Failed to emit event"); }); }
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 10, "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_3964809568807133229_0_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs /// Use the well-known ISO 8601 format when serializing and deserializing an /// [`PrimitiveDateTime`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod iso8601 { use std::num::NonZeroU8; use serde::{ser::Error as _, Deserializer, Serialize, Serializer}; use time::{ format_description::well_known::{ iso8601::{Config, EncodedConfig, TimePrecision}, Iso8601, }, serde::iso8601, PrimitiveDateTime, UtcOffset,
{ "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_3964809568807133229_0_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs /// Use the well-known ISO 8601 format when serializing and deserializing an /// [`PrimitiveDateTime`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod iso8601 { use std::num::NonZeroU8; use serde::{ser::Error as _, Deserializer, Serialize, Serializer}; use time::{ format_description::well_known::{ iso8601::{Config, EncodedConfig, TimePrecision}, Iso8601, }, serde::iso8601, PrimitiveDateTime, UtcOffset, }; const FORMAT_CONFIG: EncodedConfig = Config::DEFAULT .set_time_precision(TimePrecision::Second { decimal_digits: NonZeroU8::new(3), }) .encode(); /// Serialize a [`PrimitiveDateTime`] using the well-known ISO 8601 format. pub fn serialize<S>(date_time: &PrimitiveDateTime, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .assume_utc()
{ "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_3964809568807133229_0_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs /// Use the well-known ISO 8601 format when serializing and deserializing an /// [`PrimitiveDateTime`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod iso8601 { use std::num::NonZeroU8; use serde::{ser::Error as _, Deserializer, Serialize, Serializer}; use time::{ format_description::well_known::{ iso8601::{Config, EncodedConfig, TimePrecision}, Iso8601, }, serde::iso8601, PrimitiveDateTime, UtcOffset, }; const FORMAT_CONFIG: EncodedConfig = Config::DEFAULT .set_time_precision(TimePrecision::Second { decimal_digits: NonZeroU8::new(3), }) .encode(); /// Serialize a [`PrimitiveDateTime`] using the well-known ISO 8601 format. pub fn serialize<S>(date_time: &PrimitiveDateTime, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .assume_utc() .format(&Iso8601::<FORMAT_CONFIG>) .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, { iso8601::deserialize(deserializer).map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) } /// Use the well-known ISO 8601 format when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime
{ "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_3964809568807133229_25_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs where S: Serializer, { date_time .assume_utc() .format(&Iso8601::<FORMAT_CONFIG>) .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, {
{ "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_3964809568807133229_25_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs where S: Serializer, { date_time .assume_utc() .format(&Iso8601::<FORMAT_CONFIG>) .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, { iso8601::deserialize(deserializer).map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) } /// Use the well-known ISO 8601 format when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option { use serde::Serialize; use time::format_description::well_known::Iso8601; use super::*;
{ "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_3964809568807133229_25_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs where S: Serializer, { date_time .assume_utc() .format(&Iso8601::<FORMAT_CONFIG>) .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, { iso8601::deserialize(deserializer).map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) } /// Use the well-known ISO 8601 format when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option { use serde::Serialize; use time::format_description::well_known::Iso8601; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| date_time.assume_utc().format(&Iso8601::<FORMAT_CONFIG>)) .transpose() .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>,
{ "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_3964809568807133229_50_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs pub mod option { use serde::Serialize; use time::format_description::well_known::Iso8601; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_3964809568807133229_50_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs pub mod option { use serde::Serialize; use time::format_description::well_known::Iso8601; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| date_time.assume_utc().format(&Iso8601::<FORMAT_CONFIG>)) .transpose() .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { iso8601::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time())
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 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_3964809568807133229_50_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs pub mod option { use serde::Serialize; use time::format_description::well_known::Iso8601; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| date_time.assume_utc().format(&Iso8601::<FORMAT_CONFIG>)) .transpose() .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { iso8601::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) }) } } /// Use the well-known ISO 8601 format which is without timezone when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option_without_timezone { use serde::{de, Deserialize, Serialize}; use time::macros::format_description; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format which is without timezone. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where
{ "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_3964809568807133229_75_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs { iso8601::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) }) } } /// Use the well-known ISO 8601 format which is without timezone when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option_without_timezone { use serde::{de, Deserialize, Serialize};
{ "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_3964809568807133229_75_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs { iso8601::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) }) } } /// Use the well-known ISO 8601 format which is without timezone when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option_without_timezone { use serde::{de, Deserialize, Serialize}; use time::macros::format_description; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format which is without timezone. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| { let format =
{ "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_3964809568807133229_75_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs { iso8601::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) }) } } /// Use the well-known ISO 8601 format which is without timezone when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option_without_timezone { use serde::{de, Deserialize, Serialize}; use time::macros::format_description; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] using the well-known ISO 8601 format which is without timezone. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| { let format = format_description!("[year]-[month]-[day]T[hour]:[minute]:[second]"); date_time.assume_utc().format(format) }) .transpose() .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { Option::deserialize(deserializer)? .map(|time_string| { let format = format_description!("[year]-[month]-[day]T[hour]:[minute]:[second]"); PrimitiveDateTime::parse(time_string, format).map_err(|_| { de::Error::custom(format!( "Failed to parse PrimitiveDateTime from {time_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": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_3964809568807133229_100_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs S: Serializer, { date_time .map(|date_time| { let format = format_description!("[year]-[month]-[day]T[hour]:[minute]:[second]"); date_time.assume_utc().format(format) }) .transpose() .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, 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": 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_3964809568807133229_100_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs S: Serializer, { date_time .map(|date_time| { let format = format_description!("[year]-[month]-[day]T[hour]:[minute]:[second]"); date_time.assume_utc().format(format) }) .transpose() .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { Option::deserialize(deserializer)? .map(|time_string| { let format = format_description!("[year]-[month]-[day]T[hour]:[minute]:[second]"); PrimitiveDateTime::parse(time_string, format).map_err(|_| { de::Error::custom(format!( "Failed to parse PrimitiveDateTime from {time_string}" )) }) }) .transpose() }
{ "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_3964809568807133229_100_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs S: Serializer, { date_time .map(|date_time| { let format = format_description!("[year]-[month]-[day]T[hour]:[minute]:[second]"); date_time.assume_utc().format(format) }) .transpose() .map_err(S::Error::custom)? .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from its ISO 8601 representation. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { Option::deserialize(deserializer)? .map(|time_string| { let format = format_description!("[year]-[month]-[day]T[hour]:[minute]:[second]"); PrimitiveDateTime::parse(time_string, format).map_err(|_| { de::Error::custom(format!( "Failed to parse PrimitiveDateTime from {time_string}" )) }) }) .transpose() } } } /// Use the UNIX timestamp when serializing and deserializing an /// [`PrimitiveDateTime`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod timestamp { use serde::{Deserializer, Serialize, Serializer}; use time::{serde::timestamp, PrimitiveDateTime, UtcOffset}; /// Serialize a [`PrimitiveDateTime`] using UNIX timestamp. pub fn serialize<S>(date_time: &PrimitiveDateTime, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .assume_utc() .unix_timestamp()
{ "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_3964809568807133229_125_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs )) }) }) .transpose() } } } /// Use the UNIX timestamp when serializing and deserializing an /// [`PrimitiveDateTime`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod timestamp { use serde::{Deserializer, Serialize, Serializer};
{ "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_3964809568807133229_125_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs )) }) }) .transpose() } } } /// Use the UNIX timestamp when serializing and deserializing an /// [`PrimitiveDateTime`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod timestamp { use serde::{Deserializer, Serialize, Serializer}; use time::{serde::timestamp, PrimitiveDateTime, UtcOffset}; /// Serialize a [`PrimitiveDateTime`] using UNIX timestamp. pub fn serialize<S>(date_time: &PrimitiveDateTime, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .assume_utc() .unix_timestamp() .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, 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": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_3964809568807133229_125_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs )) }) }) .transpose() } } } /// Use the UNIX timestamp when serializing and deserializing an /// [`PrimitiveDateTime`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod timestamp { use serde::{Deserializer, Serialize, Serializer}; use time::{serde::timestamp, PrimitiveDateTime, UtcOffset}; /// Serialize a [`PrimitiveDateTime`] using UNIX timestamp. pub fn serialize<S>(date_time: &PrimitiveDateTime, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .assume_utc() .unix_timestamp() .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, { timestamp::deserialize(deserializer).map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) } /// Use the UNIX timestamp when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option { use serde::Serialize; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp. pub fn serialize<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": 125, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_3964809568807133229_150_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, { timestamp::deserialize(deserializer).map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) } /// Use the UNIX timestamp when serializing and deserializing an
{ "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_3964809568807133229_150_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, { timestamp::deserialize(deserializer).map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) } /// Use the UNIX timestamp when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option { use serde::Serialize; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer,
{ "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_3964809568807133229_150_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs .serialize(serializer) } /// Deserialize an [`PrimitiveDateTime`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<PrimitiveDateTime, D::Error> where D: Deserializer<'a>, { timestamp::deserialize(deserializer).map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) } /// Use the UNIX timestamp when serializing and deserializing an /// [`Option<PrimitiveDateTime>`][PrimitiveDateTime]. /// /// [PrimitiveDateTime]: ::time::PrimitiveDateTime pub mod option { use serde::Serialize; use super::*; /// Serialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp. pub fn serialize<S>( date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| date_time.assume_utc().unix_timestamp()) .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { timestamp::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) }) } } }
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 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_3964809568807133229_175_15
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| date_time.assume_utc().unix_timestamp()) .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>,
{ "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_3964809568807133229_175_30
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| date_time.assume_utc().unix_timestamp()) .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { timestamp::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) }) } } }
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 25, "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_3964809568807133229_175_50
clm
snippet
// connector-service/backend/common_utils/src/custom_serde.rs date_time: &Option<PrimitiveDateTime>, serializer: S, ) -> Result<S::Ok, S::Error> where S: Serializer, { date_time .map(|date_time| date_time.assume_utc().unix_timestamp()) .serialize(serializer) } /// Deserialize an [`Option<PrimitiveDateTime>`] from UNIX timestamp. pub fn deserialize<'a, D>(deserializer: D) -> Result<Option<PrimitiveDateTime>, D::Error> where D: Deserializer<'a>, { timestamp::option::deserialize(deserializer).map(|option_offset_date_time| { option_offset_date_time.map(|offset_date_time| { let utc_date_time = offset_date_time.to_offset(UtcOffset::UTC); PrimitiveDateTime::new(utc_date_time.date(), utc_date_time.time()) }) }) } } }
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 25, "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_-4895347235318218796_0_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs use error_stack::ResultExt; use crate::{ errors::CustomResult, global_id::{CellId, GlobalEntity, GlobalId}, }; /// A global id that can be used to identify a payment method #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalPaymentMethodId(GlobalId); /// A global id that can be used to identify a payment method session #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 15, "method_name": null, "num_enums": null, "num_items": null, "num_structs": null, "repo": "connector-service", "start_line": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4895347235318218796_0_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs use error_stack::ResultExt; use crate::{ errors::CustomResult, global_id::{CellId, GlobalEntity, GlobalId}, }; /// A global id that can be used to identify a payment method #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalPaymentMethodId(GlobalId); /// A global id that can be used to identify a payment method session #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalPaymentMethodSessionId(GlobalId); #[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)] pub enum GlobalPaymentMethodIdError { #[error("Failed to construct GlobalPaymentMethodId")] ConstructionError, } #[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)] pub enum GlobalPaymentMethodSessionIdError { #[error("Failed to construct GlobalPaymentMethodSessionId")] ConstructionError, } impl GlobalPaymentMethodSessionId {
{ "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_-4895347235318218796_0_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs use error_stack::ResultExt; use crate::{ errors::CustomResult, global_id::{CellId, GlobalEntity, GlobalId}, }; /// A global id that can be used to identify a payment method #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalPaymentMethodId(GlobalId); /// A global id that can be used to identify a payment method session #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalPaymentMethodSessionId(GlobalId); #[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)] pub enum GlobalPaymentMethodIdError { #[error("Failed to construct GlobalPaymentMethodId")] ConstructionError, } #[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)] pub enum GlobalPaymentMethodSessionIdError { #[error("Failed to construct GlobalPaymentMethodSessionId")] ConstructionError, } impl GlobalPaymentMethodSessionId { /// Create a new GlobalPaymentMethodSessionId from cell id information pub fn generate( cell_id: &CellId, ) -> error_stack::Result<Self, GlobalPaymentMethodSessionIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethodSession); Ok(Self(global_id)) } /// Get the string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Construct a redis key from the id to be stored in redis pub fn get_redis_key(&self) -> String { format!("payment_method_session:{}", self.get_string_repr()) } } impl crate::events::ApiEventMetric for GlobalPaymentMethodSessionId {
{ "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_-4895347235318218796_25_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs #[error("Failed to construct GlobalPaymentMethodSessionId")] ConstructionError, } impl GlobalPaymentMethodSessionId { /// Create a new GlobalPaymentMethodSessionId from cell id information pub fn generate( cell_id: &CellId, ) -> error_stack::Result<Self, GlobalPaymentMethodSessionIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethodSession); Ok(Self(global_id)) } /// Get the string representation of the id 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_-4895347235318218796_25_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs #[error("Failed to construct GlobalPaymentMethodSessionId")] ConstructionError, } impl GlobalPaymentMethodSessionId { /// Create a new GlobalPaymentMethodSessionId from cell id information pub fn generate( cell_id: &CellId, ) -> error_stack::Result<Self, GlobalPaymentMethodSessionIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethodSession); Ok(Self(global_id)) } /// Get the string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Construct a redis key from the id to be stored in redis pub fn get_redis_key(&self) -> String { format!("payment_method_session:{}", self.get_string_repr()) } } impl crate::events::ApiEventMetric for GlobalPaymentMethodSessionId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::PaymentMethodSession { payment_method_session_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": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4895347235318218796_25_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs #[error("Failed to construct GlobalPaymentMethodSessionId")] ConstructionError, } impl GlobalPaymentMethodSessionId { /// Create a new GlobalPaymentMethodSessionId from cell id information pub fn generate( cell_id: &CellId, ) -> error_stack::Result<Self, GlobalPaymentMethodSessionIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethodSession); Ok(Self(global_id)) } /// Get the string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Construct a redis key from the id to be stored in redis pub fn get_redis_key(&self) -> String { format!("payment_method_session:{}", self.get_string_repr()) } } impl crate::events::ApiEventMetric for GlobalPaymentMethodSessionId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::PaymentMethodSession { payment_method_session_id: self.clone(), }) } } impl GlobalPaymentMethodId { /// Create a new GlobalPaymentMethodId from cell id information pub fn generate(cell_id: &CellId) -> error_stack::Result<Self, GlobalPaymentMethodIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethod); Ok(Self(global_id)) } /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Construct a new GlobalPaymentMethodId from a string pub fn generate_from_string(value: String) -> CustomResult<Self, GlobalPaymentMethodIdError> { let id = GlobalId::from_string(value.into()) .change_context(GlobalPaymentMethodIdError::ConstructionError)?; Ok(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": 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_-4895347235318218796_50_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::PaymentMethodSession { payment_method_session_id: self.clone(), }) } } impl GlobalPaymentMethodId { /// Create a new GlobalPaymentMethodId from cell id information pub fn generate(cell_id: &CellId) -> error_stack::Result<Self, GlobalPaymentMethodIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethod); Ok(Self(global_id)) } /// Get string representation of the 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": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-4895347235318218796_50_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::PaymentMethodSession { payment_method_session_id: self.clone(), }) } } impl GlobalPaymentMethodId { /// Create a new GlobalPaymentMethodId from cell id information pub fn generate(cell_id: &CellId) -> error_stack::Result<Self, GlobalPaymentMethodIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethod); Ok(Self(global_id)) } /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Construct a new GlobalPaymentMethodId from a string pub fn generate_from_string(value: String) -> CustomResult<Self, GlobalPaymentMethodIdError> { let id = GlobalId::from_string(value.into()) .change_context(GlobalPaymentMethodIdError::ConstructionError)?; Ok(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": 26, "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_-4895347235318218796_50_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment_methods.rs fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::PaymentMethodSession { payment_method_session_id: self.clone(), }) } } impl GlobalPaymentMethodId { /// Create a new GlobalPaymentMethodId from cell id information pub fn generate(cell_id: &CellId) -> error_stack::Result<Self, GlobalPaymentMethodIdError> { let global_id = GlobalId::generate(cell_id, GlobalEntity::PaymentMethod); Ok(Self(global_id)) } /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Construct a new GlobalPaymentMethodId from a string pub fn generate_from_string(value: String) -> CustomResult<Self, GlobalPaymentMethodIdError> { let id = GlobalId::from_string(value.into()) .change_context(GlobalPaymentMethodIdError::ConstructionError)?; Ok(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": 26, "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_2591687643226154011_0_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/refunds.rs use error_stack::ResultExt; use crate::{errors, global_id::CellId}; /// A global id that can be used to identify a refund #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalRefundId(super::GlobalId); impl GlobalRefundId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2591687643226154011_0_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/refunds.rs use error_stack::ResultExt; use crate::{errors, global_id::CellId}; /// A global id that can be used to identify a refund #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalRefundId(super::GlobalId); impl GlobalRefundId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalRefundId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Refund); Self(global_id) } } // TODO: refactor the macro to include this id use case as well impl TryFrom<std::borrow::Cow<'static, str>> for GlobalRefundId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let merchant_ref_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "refund_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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_2591687643226154011_0_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/refunds.rs use error_stack::ResultExt; use crate::{errors, global_id::CellId}; /// A global id that can be used to identify a refund #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct GlobalRefundId(super::GlobalId); impl GlobalRefundId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalRefundId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Refund); Self(global_id) } } // TODO: refactor the macro to include this id use case as well impl TryFrom<std::borrow::Cow<'static, str>> for GlobalRefundId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let merchant_ref_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "refund_id", }, )?; 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": 34, "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_4154652033531294868_0_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/token.rs use crate::global_id::CellId; crate::global_id_type!( GlobalTokenId, "A global id that can be used to identify a token. The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`. Example: `cell1_tok_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalTokenId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4154652033531294868_0_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/token.rs use crate::global_id::CellId; crate::global_id_type!( GlobalTokenId, "A global id that can be used to identify a token. The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`. Example: `cell1_tok_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalTokenId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalTokenId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Token); Self(global_id) } } impl crate::events::ApiEventMetric for GlobalTokenId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::Token { token_id: Some(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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_4154652033531294868_0_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/token.rs use crate::global_id::CellId; crate::global_id_type!( GlobalTokenId, "A global id that can be used to identify a token. The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`. Example: `cell1_tok_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalTokenId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalTokenId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Token); Self(global_id) } } impl crate::events::ApiEventMetric for GlobalTokenId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::Token { token_id: Some(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": 31, "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_-6586181602109849698_0_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs use common_enums::enums; use error_stack::ResultExt; use crate::{errors, global_id::CellId}; crate::global_id_type!( GlobalPaymentId, "A global id that can be used to identify a payment. The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`. Example: `cell1_pay_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalPaymentId {
{ "chunk": null, "crate": "ucs_common_utils", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 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_-6586181602109849698_0_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs use common_enums::enums; use error_stack::ResultExt; use crate::{errors, global_id::CellId}; crate::global_id_type!( GlobalPaymentId, "A global id that can be used to identify a payment. The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`. Example: `cell1_pay_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalPaymentId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalPaymentId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Payment); Self(global_id) } /// Generate the id for revenue recovery Execute PT workflow pub fn get_execute_revenue_recovery_id( &self, task: &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": 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_-6586181602109849698_0_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs use common_enums::enums; use error_stack::ResultExt; use crate::{errors, global_id::CellId}; crate::global_id_type!( GlobalPaymentId, "A global id that can be used to identify a payment. The format will be `<cell_id>_<entity_prefix>_<time_ordered_id>`. Example: `cell1_pay_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalPaymentId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalPaymentId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Payment); Self(global_id) } /// Generate the id for revenue recovery Execute PT workflow pub fn get_execute_revenue_recovery_id( &self, task: &str, runner: enums::ProcessTrackerRunner, ) -> String { format!("{runner}_{task}_{}", self.get_string_repr()) } } // TODO: refactor the macro to include this id use case as well impl TryFrom<std::borrow::Cow<'static, str>> for GlobalPaymentId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let merchant_ref_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }, )?; Ok(Self(merchant_ref_id)) } } crate::global_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": 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_-6586181602109849698_25_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs /// Generate the id for revenue recovery Execute PT workflow pub fn get_execute_revenue_recovery_id( &self, task: &str, runner: enums::ProcessTrackerRunner, ) -> String { format!("{runner}_{task}_{}", self.get_string_repr()) } } // TODO: refactor the macro to include this id use case as well impl TryFrom<std::borrow::Cow<'static, str>> for GlobalPaymentId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::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": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-6586181602109849698_25_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs /// Generate the id for revenue recovery Execute PT workflow pub fn get_execute_revenue_recovery_id( &self, task: &str, runner: enums::ProcessTrackerRunner, ) -> String { format!("{runner}_{task}_{}", self.get_string_repr()) } } // TODO: refactor the macro to include this id use case as well impl TryFrom<std::borrow::Cow<'static, str>> for GlobalPaymentId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let merchant_ref_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }, )?; Ok(Self(merchant_ref_id)) } } crate::global_id_type!( GlobalAttemptId, "A global id that can be used to identify a payment attempt" ); impl GlobalAttemptId {
{ "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_-6586181602109849698_25_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs /// Generate the id for revenue recovery Execute PT workflow pub fn get_execute_revenue_recovery_id( &self, task: &str, runner: enums::ProcessTrackerRunner, ) -> String { format!("{runner}_{task}_{}", self.get_string_repr()) } } // TODO: refactor the macro to include this id use case as well impl TryFrom<std::borrow::Cow<'static, str>> for GlobalPaymentId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let merchant_ref_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }, )?; Ok(Self(merchant_ref_id)) } } crate::global_id_type!( GlobalAttemptId, "A global id that can be used to identify a payment attempt" ); impl GlobalAttemptId { /// Generate a new GlobalAttemptId from a cell id #[allow(dead_code)] pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Attempt); Self(global_id) } /// Get string representation of the id #[allow(dead_code)] pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate the id for Revenue Recovery Psync PT workflow #[allow(dead_code)] pub fn get_psync_revenue_recovery_id( &self, task: &str, runner: enums::ProcessTrackerRunner, ) -> 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": 25, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-6586181602109849698_50_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs GlobalAttemptId, "A global id that can be used to identify a payment attempt" ); impl GlobalAttemptId { /// Generate a new GlobalAttemptId from a cell id #[allow(dead_code)] pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Attempt); Self(global_id) } /// Get string representation of the id #[allow(dead_code)] 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": 50, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-6586181602109849698_50_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs GlobalAttemptId, "A global id that can be used to identify a payment attempt" ); impl GlobalAttemptId { /// Generate a new GlobalAttemptId from a cell id #[allow(dead_code)] pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Attempt); Self(global_id) } /// Get string representation of the id #[allow(dead_code)] pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate the id for Revenue Recovery Psync PT workflow #[allow(dead_code)] pub fn get_psync_revenue_recovery_id( &self, task: &str, runner: enums::ProcessTrackerRunner, ) -> String { format!("{runner}_{task}_{}", self.get_string_repr()) } } impl TryFrom<std::borrow::Cow<'static, str>> for GlobalAttemptId {
{ "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_-6586181602109849698_50_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs GlobalAttemptId, "A global id that can be used to identify a payment attempt" ); impl GlobalAttemptId { /// Generate a new GlobalAttemptId from a cell id #[allow(dead_code)] pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Attempt); Self(global_id) } /// Get string representation of the id #[allow(dead_code)] pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate the id for Revenue Recovery Psync PT workflow #[allow(dead_code)] pub fn get_psync_revenue_recovery_id( &self, task: &str, runner: enums::ProcessTrackerRunner, ) -> String { format!("{runner}_{task}_{}", self.get_string_repr()) } } impl TryFrom<std::borrow::Cow<'static, str>> for GlobalAttemptId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let global_attempt_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }, )?; Ok(Self(global_attempt_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": 40, "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_-6586181602109849698_75_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs format!("{runner}_{task}_{}", self.get_string_repr()) } } impl TryFrom<std::borrow::Cow<'static, str>> for GlobalAttemptId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let global_attempt_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }, )?; Ok(Self(global_attempt_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": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-6586181602109849698_75_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs format!("{runner}_{task}_{}", self.get_string_repr()) } } impl TryFrom<std::borrow::Cow<'static, str>> for GlobalAttemptId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let global_attempt_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }, )?; Ok(Self(global_attempt_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": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-6586181602109849698_75_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/payment.rs format!("{runner}_{task}_{}", self.get_string_repr()) } } impl TryFrom<std::borrow::Cow<'static, str>> for GlobalAttemptId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: std::borrow::Cow<'static, str>) -> Result<Self, Self::Error> { let global_attempt_id = super::GlobalId::from_string(value).change_context( errors::ValidationError::IncorrectValueProvided { field_name: "payment_id", }, )?; Ok(Self(global_attempt_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": 75, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1764418433195637174_0_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/customer.rs use crate::{errors, global_id::CellId}; crate::global_id_type!( GlobalCustomerId, "A global id that can be used to identify a customer. Example: `cell1_cus_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalCustomerId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.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": 0, "struct_name": null, "total_crates": null, "trait_name": null }
connector-service_snippet_-1764418433195637174_0_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/customer.rs use crate::{errors, global_id::CellId}; crate::global_id_type!( GlobalCustomerId, "A global id that can be used to identify a customer. Example: `cell1_cus_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalCustomerId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalCustomerId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Customer); Self(global_id) } } impl TryFrom<GlobalCustomerId> for crate::id_type::CustomerId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: GlobalCustomerId) -> Result<Self, Self::Error> { Self::try_from(std::borrow::Cow::from(value.get_string_repr().to_owned())) } }
{ "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_-1764418433195637174_0_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/customer.rs use crate::{errors, global_id::CellId}; crate::global_id_type!( GlobalCustomerId, "A global id that can be used to identify a customer. Example: `cell1_cus_uu1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p`" ); impl GlobalCustomerId { /// Get string representation of the id pub fn get_string_repr(&self) -> &str { self.0.get_string_repr() } /// Generate a new GlobalCustomerId from a cell id pub fn generate(cell_id: &CellId) -> Self { let global_id = super::GlobalId::generate(cell_id, super::GlobalEntity::Customer); Self(global_id) } } impl TryFrom<GlobalCustomerId> for crate::id_type::CustomerId { type Error = error_stack::Report<errors::ValidationError>; fn try_from(value: GlobalCustomerId) -> Result<Self, Self::Error> { Self::try_from(std::borrow::Cow::from(value.get_string_repr().to_owned())) } } impl crate::events::ApiEventMetric for GlobalCustomerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::Customer { customer_id: Some(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": 38, "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_-1764418433195637174_25_15
clm
snippet
// connector-service/backend/common_utils/src/global_id/customer.rs fn try_from(value: GlobalCustomerId) -> Result<Self, Self::Error> { Self::try_from(std::borrow::Cow::from(value.get_string_repr().to_owned())) } } impl crate::events::ApiEventMetric for GlobalCustomerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::Customer { customer_id: Some(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": 13, "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_-1764418433195637174_25_30
clm
snippet
// connector-service/backend/common_utils/src/global_id/customer.rs fn try_from(value: GlobalCustomerId) -> Result<Self, Self::Error> { Self::try_from(std::borrow::Cow::from(value.get_string_repr().to_owned())) } } impl crate::events::ApiEventMetric for GlobalCustomerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::Customer { customer_id: Some(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": 13, "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_-1764418433195637174_25_50
clm
snippet
// connector-service/backend/common_utils/src/global_id/customer.rs fn try_from(value: GlobalCustomerId) -> Result<Self, Self::Error> { Self::try_from(std::borrow::Cow::from(value.get_string_repr().to_owned())) } } impl crate::events::ApiEventMetric for GlobalCustomerId { fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> { Some(crate::events::ApiEventsType::Customer { customer_id: Some(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": 13, "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_1661134184692456114_0_15
clm
snippet
// connector-service/backend/connector-integration/src/types.rs use std::fmt::Debug; use domain_types::{connector_types::ConnectorEnum, payment_method_data::PaymentMethodDataTypes}; use interfaces::connector_types::BoxedConnector; use crate::connectors::{ Aci, Adyen, Authorizedotnet, Bluecode, Braintree, Cashfree, Cashtocode, Checkout, Cryptopay, Cybersource, Dlocal, Elavon, Fiserv, Fiuu, Helcim, Mifinity, Nexinets, Noon, Novalnet, Payload, Paytm, Payu, Phonepe, Placetopay, Rapyd, Razorpay, RazorpayV2, Stripe, Trustpay, Volt, Worldpay, Worldpayvantiv, Xendit, }; #[derive(Clone)] pub struct ConnectorData<T: PaymentMethodDataTypes + Debug + Default + Send + Sync + 'static> { pub connector: BoxedConnector<T>,
{ "chunk": null, "crate": "connector-integration", "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_1661134184692456114_0_30
clm
snippet
// connector-service/backend/connector-integration/src/types.rs use std::fmt::Debug; use domain_types::{connector_types::ConnectorEnum, payment_method_data::PaymentMethodDataTypes}; use interfaces::connector_types::BoxedConnector; use crate::connectors::{ Aci, Adyen, Authorizedotnet, Bluecode, Braintree, Cashfree, Cashtocode, Checkout, Cryptopay, Cybersource, Dlocal, Elavon, Fiserv, Fiuu, Helcim, Mifinity, Nexinets, Noon, Novalnet, Payload, Paytm, Payu, Phonepe, Placetopay, Rapyd, Razorpay, RazorpayV2, Stripe, Trustpay, Volt, Worldpay, Worldpayvantiv, Xendit, }; #[derive(Clone)] pub struct ConnectorData<T: PaymentMethodDataTypes + Debug + Default + Send + Sync + 'static> { pub connector: BoxedConnector<T>, pub connector_name: ConnectorEnum, } impl<T: PaymentMethodDataTypes + Debug + Default + Send + Sync + 'static + serde::Serialize> ConnectorData<T> { pub fn get_connector_by_name(connector_name: &ConnectorEnum) -> Self { let connector = Self::convert_connector(*connector_name); Self { connector, connector_name: *connector_name, } } fn convert_connector(connector_name: ConnectorEnum) -> BoxedConnector<T> {
{ "chunk": null, "crate": "connector-integration", "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_1661134184692456114_0_50
clm
snippet
// connector-service/backend/connector-integration/src/types.rs use std::fmt::Debug; use domain_types::{connector_types::ConnectorEnum, payment_method_data::PaymentMethodDataTypes}; use interfaces::connector_types::BoxedConnector; use crate::connectors::{ Aci, Adyen, Authorizedotnet, Bluecode, Braintree, Cashfree, Cashtocode, Checkout, Cryptopay, Cybersource, Dlocal, Elavon, Fiserv, Fiuu, Helcim, Mifinity, Nexinets, Noon, Novalnet, Payload, Paytm, Payu, Phonepe, Placetopay, Rapyd, Razorpay, RazorpayV2, Stripe, Trustpay, Volt, Worldpay, Worldpayvantiv, Xendit, }; #[derive(Clone)] pub struct ConnectorData<T: PaymentMethodDataTypes + Debug + Default + Send + Sync + 'static> { pub connector: BoxedConnector<T>, pub connector_name: ConnectorEnum, } impl<T: PaymentMethodDataTypes + Debug + Default + Send + Sync + 'static + serde::Serialize> ConnectorData<T> { pub fn get_connector_by_name(connector_name: &ConnectorEnum) -> Self { let connector = Self::convert_connector(*connector_name); Self { connector, connector_name: *connector_name, } } fn convert_connector(connector_name: ConnectorEnum) -> BoxedConnector<T> { match connector_name { ConnectorEnum::Adyen => Box::new(Adyen::new()), ConnectorEnum::Razorpay => Box::new(Razorpay::new()), ConnectorEnum::RazorpayV2 => Box::new(RazorpayV2::new()), ConnectorEnum::Fiserv => Box::new(Fiserv::new()), ConnectorEnum::Elavon => Box::new(Elavon::new()), ConnectorEnum::Xendit => Box::new(Xendit::new()), ConnectorEnum::Checkout => Box::new(Checkout::new()), ConnectorEnum::Authorizedotnet => Box::new(Authorizedotnet::new()), ConnectorEnum::Mifinity => Box::new(Mifinity::new()), ConnectorEnum::Phonepe => Box::new(Phonepe::new()), ConnectorEnum::Cashfree => Box::new(Cashfree::new()), ConnectorEnum::Fiuu => Box::new(Fiuu::new()), ConnectorEnum::Payu => Box::new(Payu::new()), ConnectorEnum::Paytm => Box::new(Paytm::new()), ConnectorEnum::Cashtocode => Box::new(Cashtocode::new()), ConnectorEnum::Novalnet => Box::new(Novalnet::new()), ConnectorEnum::Nexinets => Box::new(Nexinets::new()), ConnectorEnum::Noon => Box::new(Noon::new()), ConnectorEnum::Volt => Box::new(Volt::new()),
{ "chunk": null, "crate": "connector-integration", "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_1661134184692456114_25_15
clm
snippet
// connector-service/backend/connector-integration/src/types.rs connector_name: *connector_name, } } fn convert_connector(connector_name: ConnectorEnum) -> BoxedConnector<T> { match connector_name { ConnectorEnum::Adyen => Box::new(Adyen::new()), ConnectorEnum::Razorpay => Box::new(Razorpay::new()), ConnectorEnum::RazorpayV2 => Box::new(RazorpayV2::new()), ConnectorEnum::Fiserv => Box::new(Fiserv::new()), ConnectorEnum::Elavon => Box::new(Elavon::new()), ConnectorEnum::Xendit => Box::new(Xendit::new()), ConnectorEnum::Checkout => Box::new(Checkout::new()), ConnectorEnum::Authorizedotnet => Box::new(Authorizedotnet::new()), ConnectorEnum::Mifinity => Box::new(Mifinity::new()),
{ "chunk": null, "crate": "connector-integration", "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_1661134184692456114_25_30
clm
snippet
// connector-service/backend/connector-integration/src/types.rs connector_name: *connector_name, } } fn convert_connector(connector_name: ConnectorEnum) -> BoxedConnector<T> { match connector_name { ConnectorEnum::Adyen => Box::new(Adyen::new()), ConnectorEnum::Razorpay => Box::new(Razorpay::new()), ConnectorEnum::RazorpayV2 => Box::new(RazorpayV2::new()), ConnectorEnum::Fiserv => Box::new(Fiserv::new()), ConnectorEnum::Elavon => Box::new(Elavon::new()), ConnectorEnum::Xendit => Box::new(Xendit::new()), ConnectorEnum::Checkout => Box::new(Checkout::new()), ConnectorEnum::Authorizedotnet => Box::new(Authorizedotnet::new()), ConnectorEnum::Mifinity => Box::new(Mifinity::new()), ConnectorEnum::Phonepe => Box::new(Phonepe::new()), ConnectorEnum::Cashfree => Box::new(Cashfree::new()), ConnectorEnum::Fiuu => Box::new(Fiuu::new()), ConnectorEnum::Payu => Box::new(Payu::new()), ConnectorEnum::Paytm => Box::new(Paytm::new()), ConnectorEnum::Cashtocode => Box::new(Cashtocode::new()), ConnectorEnum::Novalnet => Box::new(Novalnet::new()), ConnectorEnum::Nexinets => Box::new(Nexinets::new()), ConnectorEnum::Noon => Box::new(Noon::new()), ConnectorEnum::Volt => Box::new(Volt::new()), ConnectorEnum::Braintree => Box::new(Braintree::new()), ConnectorEnum::Bluecode => Box::new(Bluecode::new()), ConnectorEnum::Cryptopay => Box::new(Cryptopay::new()), ConnectorEnum::Helcim => Box::new(Helcim::new()), ConnectorEnum::Dlocal => Box::new(Dlocal::new()),
{ "chunk": null, "crate": "connector-integration", "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_1661134184692456114_25_50
clm
snippet
// connector-service/backend/connector-integration/src/types.rs connector_name: *connector_name, } } fn convert_connector(connector_name: ConnectorEnum) -> BoxedConnector<T> { match connector_name { ConnectorEnum::Adyen => Box::new(Adyen::new()), ConnectorEnum::Razorpay => Box::new(Razorpay::new()), ConnectorEnum::RazorpayV2 => Box::new(RazorpayV2::new()), ConnectorEnum::Fiserv => Box::new(Fiserv::new()), ConnectorEnum::Elavon => Box::new(Elavon::new()), ConnectorEnum::Xendit => Box::new(Xendit::new()), ConnectorEnum::Checkout => Box::new(Checkout::new()), ConnectorEnum::Authorizedotnet => Box::new(Authorizedotnet::new()), ConnectorEnum::Mifinity => Box::new(Mifinity::new()), ConnectorEnum::Phonepe => Box::new(Phonepe::new()), ConnectorEnum::Cashfree => Box::new(Cashfree::new()), ConnectorEnum::Fiuu => Box::new(Fiuu::new()), ConnectorEnum::Payu => Box::new(Payu::new()), ConnectorEnum::Paytm => Box::new(Paytm::new()), ConnectorEnum::Cashtocode => Box::new(Cashtocode::new()), ConnectorEnum::Novalnet => Box::new(Novalnet::new()), ConnectorEnum::Nexinets => Box::new(Nexinets::new()), ConnectorEnum::Noon => Box::new(Noon::new()), ConnectorEnum::Volt => Box::new(Volt::new()), ConnectorEnum::Braintree => Box::new(Braintree::new()), ConnectorEnum::Bluecode => Box::new(Bluecode::new()), ConnectorEnum::Cryptopay => Box::new(Cryptopay::new()), ConnectorEnum::Helcim => Box::new(Helcim::new()), ConnectorEnum::Dlocal => Box::new(Dlocal::new()), ConnectorEnum::Placetopay => Box::new(Placetopay::new()), ConnectorEnum::Rapyd => Box::new(Rapyd::new()), ConnectorEnum::Aci => Box::new(Aci::new()), ConnectorEnum::Trustpay => Box::new(Trustpay::new()), ConnectorEnum::Stripe => Box::new(Stripe::new()), ConnectorEnum::Cybersource => Box::new(Cybersource::new()), ConnectorEnum::Worldpay => Box::new(Worldpay::new()), ConnectorEnum::Worldpayvantiv => Box::new(Worldpayvantiv::new()), ConnectorEnum::Payload => Box::new(Payload::new()), } } } pub struct ResponseRouterData<Response, RouterData> { pub response: Response, pub router_data: RouterData, pub http_code: u16, }
{ "chunk": null, "crate": "connector-integration", "enum_name": null, "file_size": null, "for_type": null, "function_name": null, "is_async": null, "is_pub": null, "lines": 48, "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 }