diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-05-18 15:21:14 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-05-23 12:17:59 +0200 |
commit | 383840b8dbad8c6456cf81a39c54aca8958fe08c (patch) | |
tree | 85b7cb73f209ca2eb65e782143268d1275eb3955 | |
parent | ada54aecec58acb658366f442849818f1b83a103 (diff) |
plugin_measurement_filter: Change config type to use typed address configuration
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r-- | plugins/plugin_measurement_filter/src/builder.rs | 4 | ||||
-rw-r--r-- | plugins/plugin_measurement_filter/src/config.rs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/plugins/plugin_measurement_filter/src/builder.rs b/plugins/plugin_measurement_filter/src/builder.rs index 6f3b2105..d76a2599 100644 --- a/plugins/plugin_measurement_filter/src/builder.rs +++ b/plugins/plugin_measurement_filter/src/builder.rs @@ -59,11 +59,11 @@ where .try_into::<MeasurementFilterConfig>() .map_err(crate::error::Error::from)?; - let main_addr = plugin_dir.get_address_for(&config.target)?; + let main_addr = config.target.build(plugin_dir)?; let filtered_addr = config .filtered_target .as_ref() - .map(|filtered| plugin_dir.get_address_for(filtered)) + .map(|filtered| filtered.build(plugin_dir)) .transpose()?; Ok({ diff --git a/plugins/plugin_measurement_filter/src/config.rs b/plugins/plugin_measurement_filter/src/config.rs index 6081e853..f8c6ea32 100644 --- a/plugins/plugin_measurement_filter/src/config.rs +++ b/plugins/plugin_measurement_filter/src/config.rs @@ -2,10 +2,10 @@ #[serde_with::serde_as] pub struct MeasurementFilterConfig { /// The name of the plugin to send the measurements to if the filter did not match its value - pub(crate) target: String, + pub(crate) target: tedge_lib::config::Address, /// The name of the plugin to send measurements to if the filter matched its value - pub(crate) filtered_target: Option<String>, + pub(crate) filtered_target: Option<tedge_lib::config::Address>, /// A path to find the value inside a measurement #[serde_as(as = "TryFromInto<String>")] @@ -32,8 +32,8 @@ mod tests { "#; let c: MeasurementFilterConfig = toml::from_str(s).unwrap(); - assert_eq!(c.target, "foo"); - assert_eq!(c.filtered_target, Some("bar".to_string())); + assert_eq!(c.target.as_ref(), "foo"); + assert_eq!(c.filtered_target.as_ref().map(AsRef::as_ref), Some("bar")); assert_eq!( c.extractor.0, vec![Token::Key("foo".to_string()), Token::Key("bar".to_string())] |