Skip to main content

rsiot/components/cmp_esp_mqtt_client/
component.rs

1use async_trait::async_trait;
2
3use crate::{
4    executor::{CmpResult, Component, IComponentProcess, MsgBusLinker},
5    message::MsgDataBound,
6};
7
8use super::{config::Config, fn_process::fn_process};
9
10/// Название компонента
11pub const COMPONENT_NAME: &str = "cmp_esp_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
26/// Компонент cmp_esp_mqtt_client
27pub type Cmp<TMsg> = Component<Config<TMsg>, TMsg>;