Skip to main content

rsiot/components/cmp_http_server/
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_http_server";
12
13#[cfg_attr(not(feature = "single-thread"), async_trait)]
14#[cfg_attr(feature = "single-thread", async_trait(?Send))]
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: Config<TMsg>,
22        msgbus_linker: MsgBusLinker<TMsg>,
23    ) -> Result<(), ComponentError> {
24        fn_process(msgbus_linker.init(COMPONENT_NAME), config).await?;
25        Ok(())
26    }
27}
28
29/// Компонент cmp_http_server
30pub type Cmp<TMsg> = Component<Config<TMsg>, TMsg>;