rsiot/components/cmp_esp_led/
component.rs1use async_trait::async_trait;
2use esp_idf_svc::hal::{peripheral::Peripheral, rmt::RmtChannel};
3
4use crate::{
5 executor::{CmpInOut, CmpResult, Component, IComponentProcess},
6 message::{AuthPermissions, MsgDataBound},
7};
8
9use super::{config::Config, fn_process::fn_process};
10
11#[cfg_attr(not(feature = "single-thread"), async_trait)]
12#[cfg_attr(feature = "single-thread", async_trait(?Send))]
13impl<TMsg, TPeripheral, TRmt> IComponentProcess<Config<TMsg, TPeripheral, TRmt>, TMsg>
14 for Component<Config<TMsg, TPeripheral, TRmt>, TMsg>
15where
16 TMsg: MsgDataBound + 'static,
17 TRmt: Peripheral<P = TPeripheral> + 'static,
18 TPeripheral: RmtChannel,
19{
20 async fn process(
21 &self,
22 config: Config<TMsg, TPeripheral, TRmt>,
23 msg_bus: CmpInOut<TMsg>,
24 ) -> CmpResult {
25 let in_out = msg_bus.clone_with_new_id("cmp_esp_led", AuthPermissions::FullAccess);
26 fn_process(config, in_out).await?;
27 Ok(())
28 }
29}
30
31pub type Cmp<TMsg, TPeripheral, TRmt> = Component<Config<TMsg, TPeripheral, TRmt>, TMsg>;