diff options
author | Marcel Müller <m.mueller@ifm.com> | 2022-05-19 14:31:04 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-05-20 12:16:28 +0200 |
commit | 295676c596eefc334e20503858d67ecc2bc51f8f (patch) | |
tree | 85e50eaa48d7ad7424809db98de4eac121f6c988 | |
parent | 02272e24a128f273416c92cd7c00e2b97ca19a02 (diff) |
Add default bodies to tedge_api::Plugin
This patch adds default bodies for the `Plugin` trait methods, as some
plugins don't want to do anything in these functions, so they would
implement them with simply returning `Ok(())` anyways, which we can do
here equally good.
This results in less brain-load on the Plugin authors side as well.
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
Reviewed-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r-- | crates/core/tedge_api/src/plugin.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/core/tedge_api/src/plugin.rs b/crates/core/tedge_api/src/plugin.rs index c4722c1c..0ffbe551 100644 --- a/crates/core/tedge_api/src/plugin.rs +++ b/crates/core/tedge_api/src/plugin.rs @@ -311,14 +311,18 @@ pub trait Plugin: Sync + Send + DowncastSync { /// /// This function will be called by the core of thin-edge before any message-passing starts. /// The plugin is free to for example spawn up background tasks here. - async fn start(&mut self) -> Result<(), PluginError>; + async fn start(&mut self) -> Result<(), PluginError> { + Ok(()) + } /// Gracefully handle shutdown /// /// This function is called by the core of thin-edge before the software shuts down as a whole, /// giving the plugin the opportunity to clear up resources (e.g. deallocate file handles /// cleanly, shut down network connections properly, etc...). - async fn shutdown(&mut self) -> Result<(), PluginError>; + async fn shutdown(&mut self) -> Result<(), PluginError> { + Ok(()) + } } impl_downcast!(sync Plugin); |