rsiot/components/cmp_mqtt_client/
component.rs1use async_trait::async_trait;
2
3use crate::{
4 executor::{MsgBusLinker, CmpResult, Component, IComponentProcess},
5 message::MsgDataBound,
6};
7
8use super::{config::Config, fn_process::fn_process};
9
10pub const COMPONENT_NAME: &str = "cmp_mqtt_client";
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(&self, config: Config<TMsg>, msg_bus: MsgBusLinker<TMsg>) -> CmpResult {
20 let msg_bus = msg_bus.init(COMPONENT_NAME);
21 fn_process(config, msg_bus).await?;
22 Ok(())
23 }
24}
25
26pub type Cmp<TMsg> = Component<Config<TMsg>, TMsg>;