From a10d31bc0d95c2ce89d624db8e6ec0cb27632f10 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 27 Sep 2022 09:12:36 +0200 Subject: 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 --- crates/core/tedge_core/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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>)>, + message_types: HashSet, } 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 { + &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>)>, errors: Vec, + message_types: HashSet, } 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 -- cgit v1.2.3