rsiot/components/cmp_slint/
component.rs1use async_trait::async_trait;
2use slint::ComponentHandle;
3
4use crate::{
5 executor::{Component, ComponentError, IComponentProcess, MsgBusLinker},
6 message::MsgDataBound,
7};
8
9use super::{Config, fn_process::fn_process};
10
11pub const COMPONENT_NAME: &str = "cmp_slint";
13
14#[cfg_attr(not(feature = "single-thread"), async_trait)]
15#[cfg_attr(feature = "single-thread", async_trait(?Send))]
16impl<TMainWindow, TMsg> IComponentProcess<Config<TMsg, TMainWindow>, TMsg>
17 for Component<Config<TMsg, TMainWindow>, TMsg>
18where
19 TMsg: MsgDataBound + 'static,
20 Self: Sync,
21 TMainWindow: ComponentHandle + 'static,
22{
23 async fn process(
24 &self,
25 config: Config<TMsg, TMainWindow>,
26 msgbus_linker: MsgBusLinker<TMsg>,
27 ) -> Result<(), ComponentError> {
28 fn_process(config, msgbus_linker.init(COMPONENT_NAME)).await?;
29 Ok(())
30 }
31}
32
33pub type Cmp<TMsg, TMainWindow> = Component<Config<TMsg, TMainWindow>, TMsg>;