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