diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-05-12 12:23:34 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-05-12 14:52:34 +0200 |
commit | 52c5e027a1e876a4e6b5863002d5a70324be41db (patch) | |
tree | aef135d3e98915e7a85431b44260a508a86f7914 /plugins | |
parent | 6ae2e3876daa823fda80ae8a96d3dca0edbd3a5d (diff) |
plugin_inotify: Make config type self-describing
This patch rewrites the configuration type to be self-describing and
adapts the `PluginBuilder` implementation to implement the
`PluginBuilder::kind_configuration()` interface.
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/plugin_inotify/src/config.rs | 5 | ||||
-rw-r--r-- | plugins/plugin_inotify/src/lib.rs | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/plugins/plugin_inotify/src/config.rs b/plugins/plugin_inotify/src/config.rs index 0b201687..6859b4e9 100644 --- a/plugins/plugin_inotify/src/config.rs +++ b/plugins/plugin_inotify/src/config.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::path::PathBuf; -#[derive(serde::Deserialize, Debug)] +#[derive(serde::Deserialize, Debug, tedge_api::Config)] pub struct InotifyConfig { /// Target to send notifications to pub(crate) target: String, @@ -21,7 +21,8 @@ fn fail_on_err_default() -> bool { true } -#[derive(serde::Deserialize, Copy, Clone, Debug)] +#[derive(serde::Deserialize, Copy, Clone, Debug, tedge_api::Config)] +#[config(untagged)] #[allow(non_camel_case_types)] pub enum Watchmode { /// File was accessed diff --git a/plugins/plugin_inotify/src/lib.rs b/plugins/plugin_inotify/src/lib.rs index 355eee95..96d29e6d 100644 --- a/plugins/plugin_inotify/src/lib.rs +++ b/plugins/plugin_inotify/src/lib.rs @@ -43,6 +43,10 @@ impl<PD: PluginDirectory> PluginBuilder<PD> for InotifyPluginBuilder { "inotify" } + fn kind_configuration() -> Option<tedge_api::ConfigDescription> { + Some(<InotifyConfig as tedge_api::AsConfig>::as_config()) + } + fn kind_message_types() -> HandleTypes where Self: Sized, |