Common/Effect/
ApplicationRunTime.rs1use std::sync::Arc;
7
8use async_trait::async_trait;
9
10use super::ActionEffect::ActionEffect;
11use crate::{
12 Environment::{HasEnvironment::HasEnvironment, Requires::Requires},
13 Error::CommonError::CommonError,
14};
15
16#[async_trait]
18pub trait ApplicationRunTime: HasEnvironment + Send + Sync + 'static {
19 async fn Run<TCapabilityProvider, TError, TOutput>(
24 &self,
25
26 Effect:ActionEffect<Arc<TCapabilityProvider>, TError, TOutput>,
27 ) -> Result<TOutput, TError>
28 where
29 TCapabilityProvider: ?Sized + Send + Sync + 'static,
30 Self::EnvironmentType: Requires<TCapabilityProvider>,
31 TError: From<CommonError> + Send + Sync + 'static,
32 TOutput: Send + Sync + 'static;
33}
34
35#[async_trait]
38impl<TRunTime:ApplicationRunTime> ApplicationRunTime for Arc<TRunTime> {
39 async fn Run<TCapabilityProvider, TError, TOutput>(
40 &self,
41
42 Effect:ActionEffect<Arc<TCapabilityProvider>, TError, TOutput>,
43 ) -> Result<TOutput, TError>
44 where
45 TCapabilityProvider: ?Sized + Send + Sync + 'static,
46 Self::EnvironmentType: Requires<TCapabilityProvider>,
47 TError: From<CommonError> + Send + Sync + 'static,
48 TOutput: Send + Sync + 'static, {
49 (**self).Run(Effect).await
50 }
51}