rsiot/components/cmp_system_info/
component.rs1use async_trait::async_trait;
2
3use crate::{
4 executor::{Component, ComponentError, IComponentProcess, MsgBusLinker},
5 message::MsgDataBound,
6};
7
8use super::{Config, fn_process::fn_process};
9
10pub const COMPONENT_NAME: &str = "cmp_system_info";
12
13#[cfg_attr(not(feature = "single-thread"), async_trait)]
14#[cfg_attr(feature = "single-thread", async_trait(?Send))]
15impl<TMsg> IComponentProcess<Config<TMsg>, TMsg> for Component<Config<TMsg>, TMsg>
16where
17 TMsg: MsgDataBound + 'static,
18{
19 async fn process(
20 &self,
21 config: Config<TMsg>,
22 msgbus_linker: MsgBusLinker<TMsg>,
23 ) -> Result<(), ComponentError> {
24 fn_process(config, msgbus_linker.init(COMPONENT_NAME))
25 .await
26 .map_err(|err| ComponentError::Execution(err.to_string()))
27 }
28}
29
30pub type Cmp<TMsg> = Component<Config<TMsg>, TMsg>;