diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-09-27 09:12:36 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-09-27 09:12:36 +0200 |
commit | a10d31bc0d95c2ce89d624db8e6ec0cb27632f10 (patch) | |
tree | a46b7c7b58dbd7860d077cf6fecd128b9916f867 | |
parent | a70e51a105de2ace764682e0dc0451925b671b8b (diff) |
Add the message type registry in TedgeApplication
This patch adds a HashSet in TedgeApplication which will be the message
type registry.
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r-- | crates/core/tedge_core/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/core/tedge_core/src/lib.rs b/crates/core/tedge_core/src/lib.rs index ede90e39..43a80b49 100644 --- a/crates/core/tedge_core/src/lib.rs +++ b/crates/core/tedge_core/src/lib.rs @@ -1,10 +1,12 @@ #![doc = include_str!("../README.md")] use std::collections::HashMap; +use std::collections::HashSet; use std::path::Path; use std::path::PathBuf; use itertools::Itertools; +use tedge_api::message::MessageType; use tedge_api::plugin::HandleTypes; use tedge_api::PluginBuilder; use tokio_util::sync::CancellationToken; @@ -47,6 +49,7 @@ pub struct TedgeApplication { config: TedgeConfiguration, cancellation_token: CancellationToken, plugin_builders: HashMap<String, (HandleTypes, Box<dyn PluginBuilder<PluginDirectory>>)>, + message_types: HashSet<MessageType>, } impl std::fmt::Debug for TedgeApplication { @@ -63,6 +66,7 @@ impl TedgeApplication { cancellation_token: CancellationToken::new(), plugin_builders: HashMap::new(), errors: vec![], + message_types: HashSet::new(), } } @@ -80,6 +84,10 @@ impl TedgeApplication { &self.plugin_builders } + pub(crate) fn message_types(&self) -> &HashSet<MessageType> { + &self.message_types + } + pub(crate) fn cancellation_token(&self) -> &CancellationToken { &self.cancellation_token } @@ -151,6 +159,7 @@ pub struct TedgeApplicationBuilder { cancellation_token: CancellationToken, plugin_builders: HashMap<String, (HandleTypes, Box<dyn PluginBuilder<PluginDirectory>>)>, errors: Vec<TedgeApplicationBuilderError>, + message_types: HashSet<MessageType>, } impl TedgeApplicationBuilder { @@ -182,6 +191,8 @@ impl TedgeApplicationBuilder { return self; } + self.message_types + .extend(handle_types.get_types().iter().cloned()); self.plugin_builders .insert(kind_name.to_string(), (handle_types, Box::new(builder))); self |