rsiot/components/cmp_http_client_wasm/
component.rs1use async_trait::async_trait;
4
5use crate::{
6 executor::{CmpInOut, Component, ComponentError, IComponentProcess},
7 message::{AuthPermissions, MsgDataBound},
8};
9
10use super::{config::Config, fn_process::fn_process};
11
12#[allow(unreachable_code)]
13#[cfg(not(feature = "single-thread"))]
14#[async_trait]
15impl<TMsg> IComponentProcess<Config<TMsg>, TMsg> for Component<Config<TMsg>, TMsg>
16where
17 TMsg: MsgDataBound + 'static,
18{
19 async fn process(
20 &self,
21 _config: ConfigAlias<TMsg>,
22 _input: CmpInOut<TMsg>,
23 ) -> Result<(), ComponentError> {
24 unimplemented!();
25 let config = _config.0;
26 fn_process(_input, config)
27 .await
28 .map_err(|err| ComponentError::Execution(err.to_string()))
29 }
30}
31
32#[cfg(feature = "single-thread")]
33#[async_trait(?Send)]
34impl<TMsg> IComponentProcess<Config<TMsg>, TMsg> for Component<Config<TMsg>, TMsg>
35where
36 TMsg: MsgDataBound + 'static,
37{
38 async fn process(
39 &self,
40 config: Config<TMsg>,
41 in_out: CmpInOut<TMsg>,
42 ) -> Result<(), ComponentError> {
43 fn_process(
44 in_out.clone_with_new_id("cmp_http_client_wasm", AuthPermissions::FullAccess),
45 config,
46 )
47 .await
48 .map_err(|err| ComponentError::Execution(err.to_string()))
49 }
50}
51
52pub type Cmp<TMsg> = Component<Config<TMsg>, TMsg>;