rsiot/components/cmp_esp_uart_slave/
component.rs

1use async_trait::async_trait;
2use esp_idf_svc::hal::{peripheral::Peripheral, uart::Uart};
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, TUart, TPeripheral, TBufferData>
14    IComponentProcess<Config<TMsg, TUart, TPeripheral, TBufferData>, TMsg>
15    for Component<Config<TMsg, TUart, TPeripheral, TBufferData>, TMsg>
16where
17    TMsg: MsgDataBound + 'static,
18    TUart: Peripheral<P = TPeripheral> + 'static,
19    TPeripheral: Uart,
20    TBufferData: 'static,
21{
22    async fn process(
23        &self,
24        config: Config<TMsg, TUart, TPeripheral, TBufferData>,
25        msg_bus: CmpInOut<TMsg>,
26    ) -> CmpResult {
27        let in_out = msg_bus.clone_with_new_id("cmp_esp_uart_slave", AuthPermissions::FullAccess);
28        fn_process(config, in_out).await?;
29        Ok(())
30    }
31}
32
33/// Компонент cmp_esp_uart_slave
34pub type Cmp<TMsg, TUart, TPeripheral, TBufferData> =
35    Component<Config<TMsg, TUart, TPeripheral, TBufferData>, TMsg>;