Skip to main content

rsiot/components/cmp_modbus_client/
component.rs

1use async_trait::async_trait;
2
3use crate::{
4    executor::{Component, ComponentError, IComponentProcess, MsgBusLinker},
5    message::MsgDataBound,
6};
7
8use super::{config::Config, fn_process::fn_process};
9
10/// Название компонента
11pub const COMPONENT_NAME: &str = "cmp_modbus_client";
12
13#[cfg_attr(not(feature = "single-thread"), async_trait)]
14#[cfg_attr(feature = "single-thread", async_trait(?Send))]
15impl<TMessage> IComponentProcess<Config<TMessage>, TMessage>
16    for Component<Config<TMessage>, TMessage>
17where
18    TMessage: MsgDataBound + 'static,
19{
20    async fn process(
21        &self,
22        config: Config<TMessage>,
23        msgbus_linker: MsgBusLinker<TMessage>,
24    ) -> Result<(), ComponentError> {
25        fn_process(config, msgbus_linker.init(COMPONENT_NAME)).await?;
26        Ok(())
27    }
28}
29
30/// Компонент cmp_modbus_client
31pub type Cmp<TMessage> = Component<Config<TMessage>, TMessage>;