martinzink commented on code in PR #2220:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2220#discussion_r3871519483


##########
minifi_rust/minifi_native/src/api/process_context.rs:
##########
@@ -15,115 +15,42 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use crate::StandardPropertyValidator::*;
 use crate::api::RawControllerService;
 use crate::api::component_definition_traits::ComponentIdentifier;
 use crate::api::flow_file::FlowFile;
-use crate::api::property::GetControllerService;
-use crate::{
-    ControllerServiceApi, ControllerServiceDefinition, 
EnableControllerService, GetProperty,
-    MinifiError, Property,
-};
-use std::str::FromStr;
-use std::time::Duration;
+use crate::api::property::{ControllerServiceValue, GetControllerService, 
PropertySchema};
+use crate::{ControllerServiceApi, EnableControllerService, GetProperty, 
MinifiError, Property};
 
 pub trait ProcessContext {
     type FlowFile: FlowFile;
 
-    fn get_property(
+    fn get_raw_property<P: PropertySchema + ?Sized>(
         &self,
-        property: &Property,
+        property: &Property<P>,
         flow_file: Option<&Self::FlowFile>,
     ) -> Result<Option<String>, MinifiError>;
 
-    fn get_bool_property(
+    /// Returns the RawControllerService (ControllerService wrapper whose 
lifetime is managed by the agent)
+    fn get_raw_controller_service<RawCs, P>(
         &self,
-        property: &Property,
-        flow_file: Option<&Self::FlowFile>,
-    ) -> Result<Option<bool>, MinifiError> {
-        if property.validator != BoolValidator {
-            return Err(MinifiError::validation_err(format!(
-                "to use get_bool_property {:?} must have BoolValidator",
-                property
-            )));
-        }
-
-        if let Some(property_val) = self.get_property(property, flow_file)? {
-            Ok(Some(bool::from_str(&property_val)?))
-        } else {
-            Ok(None)
-        }
-    }
-
-    fn get_duration_property(
-        &self,
-        property: &Property,
-        flow_file: Option<&Self::FlowFile>,
-    ) -> Result<Option<Duration>, MinifiError> {
-        if property.validator != TimePeriodValidator {
-            return Err(MinifiError::validation_err(format!(
-                "to use get_duration_property {:?} must have 
TimePeriodValidator",
-                property
-            )));
-        }
-
-        if let Some(property_val) = self.get_property(property, flow_file)? {
-            Ok(Some(humantime::parse_duration(property_val.as_str())?))
-        } else {
-            Ok(None)
-        }
-    }
-
-    fn get_size_property(
-        &self,
-        property: &Property,
-        flow_file: Option<&Self::FlowFile>,
-    ) -> Result<Option<u64>, MinifiError> {
-        if property.validator != DataSizeValidator {
-            return Err(MinifiError::validation_err(format!(
-                "to use get_size_property {:?} must have DataSizeValidator",
-                property
-            )));
-        }
-        if let Some(property_val) = self.get_property(property, flow_file)? {
-            Ok(Some(byte_unit::Byte::from_str(&property_val)?.as_u64()))
-        } else {
-            Ok(None)
-        }
-    }
-
-    fn get_u64_property(
-        &self,
-        property: &Property,
-        flow_file: Option<&Self::FlowFile>,
-    ) -> Result<Option<u64>, MinifiError> {
-        if property.validator != U64Validator {
-            return Err(MinifiError::validation_err(format!(
-                "to use get_u64_property {:?} must have U64Validator",
-                property
-            )));
-        }
-        if let Some(property_val) = self.get_property(property, flow_file)? {
-            Ok(Some(u64::from_str(&property_val)?))
-        } else {
-            Ok(None)
-        }
-    }
+        property: &Property<P>,
+    ) -> Result<Option<&RawCs>, MinifiError>
+    where
+        RawCs: RawControllerService + ComponentIdentifier + 'static,
+        P: PropertySchema + ?Sized;
 
-    fn get_raw_controller_service<Cs>(
+    /// Returns the enabled ControllerService (managed by RawControllerService)
+    fn get_controller_service<Cs>(

Review Comment:
   yeah but the return type of these differ enough so its not trivial to merge 
them, one returns a simple Option<&T> the other Option<Box<&Trait>>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to