rsiot/components/cmp_esp_i2c_master/
component.rs1use async_trait::async_trait;
2use esp_idf_svc::hal::{i2c::I2c, peripheral::Peripheral};
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, TI2c, TPeripheral> IComponentProcess<Config<TMsg, TI2c, TPeripheral>, TMsg>
14 for Component<Config<TMsg, TI2c, TPeripheral>, TMsg>
15where
16 TMsg: MsgDataBound + 'static,
17 TI2c: Peripheral<P = TPeripheral> + 'static,
18 TPeripheral: I2c,
19{
20 async fn process(
21 &self,
22 config: Config<TMsg, TI2c, TPeripheral>,
23 in_out: CmpInOut<TMsg>,
24 ) -> CmpResult {
25 let in_out = in_out.clone_with_new_id("cmp_esp_i2c_master", AuthPermissions::FullAccess);
26 fn_process(config, in_out).await?;
27 Ok(())
28 }
29}
30
31pub type Cmp<TMsg, TI2c, TPeripheral> = Component<Config<TMsg, TI2c, TPeripheral>, TMsg>;