Skip to main content

rsiot/components/cmp_esp_can/
component.rs

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