rsiot/components/cmp_esp_nvs/
component.rs

1use async_trait::async_trait;
2use serde::{de::DeserializeOwned, Serialize};
3
4use crate::{
5    executor::{CmpInOut, Component, ComponentError, IComponentProcess},
6    message::{AuthPermissions, MsgDataBound},
7};
8
9use super::config::Config;
10#[cfg(feature = "single-thread")]
11use super::fn_process::fn_process;
12
13#[allow(unreachable_code)]
14#[cfg(not(feature = "single-thread"))]
15#[async_trait]
16impl<TMsg, TStorageData> IComponentProcess<Config<TMsg, TStorageData>, TMsg>
17    for Component<Config<TMsg, TStorageData>, TMsg>
18where
19    TMsg: MsgDataBound + 'static,
20    TStorageData: std::fmt::Debug + Default + DeserializeOwned + PartialEq + Serialize,
21{
22    async fn process(
23        &self,
24        config: Config<TMsg, TStorageData>,
25        input: CmpInOut<TMsg>,
26    ) -> Result<(), ComponentError> {
27        unimplemented!();
28    }
29}
30
31#[cfg(feature = "single-thread")]
32#[async_trait(?Send)]
33impl<TMsg, TStorageData> IComponentProcess<Config<TMsg, TStorageData>, TMsg>
34    for Component<Config<TMsg, TStorageData>, TMsg>
35where
36    TMsg: MsgDataBound + 'static,
37    TStorageData: std::fmt::Debug + Default + DeserializeOwned + PartialEq + Serialize + 'static,
38{
39    async fn process(
40        &self,
41        config: Config<TMsg, TStorageData>,
42        in_out: CmpInOut<TMsg>,
43    ) -> Result<(), ComponentError> {
44        let in_out = in_out.clone_with_new_id("cmp_storage_esp", AuthPermissions::FullAccess);
45        fn_process(in_out, config)
46            .await
47            .map_err(|err| ComponentError::Execution(err.to_string()))
48    }
49}
50
51/// Компонент cmp_storage_esp
52pub type Cmp<TMsg, TStorageData> = Component<Config<TMsg, TStorageData>, TMsg>;