rsiot/components/cmp_esp_i2c_master/
component.rs1use async_trait::async_trait;
2use esp_idf_svc::hal::i2c::I2c;
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_i2c_master";
13
14#[cfg_attr(not(feature = "single-thread"), async_trait)]
15#[cfg_attr(feature = "single-thread", async_trait(?Send))]
16impl<TMsg, TI2c> IComponentProcess<Config<TMsg, TI2c>, TMsg> for Component<Config<TMsg, TI2c>, TMsg>
17where
18 TMsg: MsgDataBound + 'static,
19 TI2c: I2c + 'static,
20{
21 async fn process(
22 &self,
23 config: Config<TMsg, TI2c>,
24 msgbus_linker: MsgBusLinker<TMsg>,
25 ) -> CmpResult {
26 fn_process(config, msgbus_linker.init(COMPONENT_NAME)).await?;
27 Ok(())
28 }
29}
30
31pub type Cmp<TMsg, TI2c> = Component<Config<TMsg, TI2c>, TMsg>;