Skip to main content

rsiot/components/cmp_telegram/
component.rs

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