rsiot_extra_components/cmp_derive/
component.rs1use async_trait::async_trait;
2
3use rsiot_component_core::{CmpInOut, Component, ComponentError, IComponentProcess};
4use rsiot_messages_core::{AuthPermissions, MsgDataBound};
5
6use super::{fn_process::fn_process, Config};
7
8#[cfg_attr(not(feature = "single-thread"), async_trait)]
9#[cfg_attr(feature = "single-thread", async_trait(?Send))]
10impl<TMsg> IComponentProcess<Config<TMsg>, TMsg> for Component<Config<TMsg>, TMsg>
11where
12 TMsg: MsgDataBound + 'static,
13{
14 async fn process(
15 &self,
16 config: Config<TMsg>,
17 in_out: CmpInOut<TMsg>,
18 ) -> Result<(), ComponentError> {
19 fn_process(
20 in_out.clone_with_new_id("cmp_derive", AuthPermissions::FullAccess),
21 config,
22 )
23 .await
24 .map_err(|e| ComponentError::Execution(e.to_string()))
25 }
26}
27
28pub type Cmp<TMsg> = Component<Config<TMsg>, TMsg>;