Skip to main content

rsiot/components/cmp_esp_led/
component.rs

1use async_trait::async_trait;
2use esp_idf_svc::hal::rmt::RmtChannel;
3
4use crate::{
5    executor::{CmpResult, Component, IComponentProcess, MsgBusLinker},
6    message::MsgDataBound,
7};
8
9use super::{config::Config, fn_process::fn_process};
10
11pub const COMPONENT_NAME: &str = "cmp_esp_led";
12
13#[cfg_attr(not(feature = "single-thread"), async_trait)]
14#[cfg_attr(feature = "single-thread", async_trait(?Send))]
15impl<TMsg, TRmt> IComponentProcess<Config<TMsg, TRmt>, TMsg> for Component<Config<TMsg, TRmt>, TMsg>
16where
17    TMsg: MsgDataBound + 'static,
18    TRmt: RmtChannel + 'static,
19{
20    async fn process(
21        &self,
22        config: Config<TMsg, TRmt>,
23        msgbus_linker: MsgBusLinker<TMsg>,
24    ) -> CmpResult {
25        let input = msgbus_linker.init(COMPONENT_NAME).input();
26        fn_process(config, input).await?;
27        Ok(())
28    }
29}
30
31/// Компонент cmp_esp_led
32pub type Cmp<TMsg, TRmt> = Component<Config<TMsg, TRmt>, TMsg>;