rsiot/components/cmp_plc/
component.rs

1use async_trait::async_trait;
2use serde::Serialize;
3
4use crate::{
5    executor::{CmpInOut, Component, ComponentError, IComponentProcess},
6    message::{AuthPermissions, MsgDataBound},
7};
8
9use super::{
10    config::Config,
11    fn_process::fn_process,
12    plc::{FunctionBlockBase, IFunctionBlock},
13};
14
15#[cfg_attr(not(feature = "single-thread"), async_trait)]
16#[cfg_attr(feature = "single-thread", async_trait(? Send))]
17impl<TMsg, I, Q, S> IComponentProcess<Config<TMsg, I, Q, S>, TMsg>
18    for Component<Config<TMsg, I, Q, S>, TMsg>
19where
20    TMsg: MsgDataBound + 'static,
21    I: Clone + Default + Send + Serialize + 'static + Sync,
22    Q: Clone + Default + Send + Serialize + 'static + Sync,
23    S: Clone + Default + Send + Serialize + 'static + Sync,
24    FunctionBlockBase<I, Q, S>: IFunctionBlock<I, Q, S>,
25{
26    async fn process(
27        &self,
28        config: Config<TMsg, I, Q, S>,
29        in_out: CmpInOut<TMsg>,
30    ) -> Result<(), ComponentError> {
31        fn_process(
32            in_out.clone_with_new_id("cmp_plc", AuthPermissions::FullAccess),
33            config,
34        )
35        .await
36        .map_err(|e| ComponentError::Execution(e.to_string()))
37    }
38}
39
40/// Компонент cmp_plc
41pub type Cmp<TMsg, I, Q, S> = Component<Config<TMsg, I, Q, S>, TMsg>;