rsiot_redis_client/
component.rs

1use async_trait::async_trait;
2
3use rsiot_component_core::{CmpInOut, Component, ComponentError, IComponentProcess};
4use rsiot_messages_core::{AuthPermissions, IMessageChannel, MsgDataBound};
5
6use crate::{config::ConfigAlias, fn_process::fn_process};
7
8#[cfg_attr(not(feature = "single-thread"), async_trait)]
9#[cfg_attr(feature = "single-thread", async_trait(?Send))]
10impl<TMessage, TMessageChannel> IComponentProcess<ConfigAlias<TMessage, TMessageChannel>, TMessage>
11    for Component<ConfigAlias<TMessage, TMessageChannel>, TMessage>
12where
13    TMessage: MsgDataBound + 'static,
14    TMessageChannel: IMessageChannel + 'static,
15    Self: Sync,
16{
17    async fn process(
18        &self,
19        config: ConfigAlias<TMessage, TMessageChannel>,
20        input: CmpInOut<TMessage>,
21    ) -> Result<(), ComponentError> {
22        let config = config.0;
23        fn_process(
24            input.clone_with_new_id("cmp_redis_client", AuthPermissions::FullAccess),
25            config,
26        )
27        .await
28    }
29}
30
31pub type Cmp<TMessage, TMessageChannel> =
32    Component<ConfigAlias<TMessage, TMessageChannel>, TMessage>;