ruva_core/bus_components/handler/command/
mod.rs1pub mod uow;
17use crate::{
18 message::TCommand,
19 prelude::{ApplicationError, ApplicationResponse, BaseError, TCommandService, TSetCurrentEvents, TUnitOfWork},
20};
21pub use uow::*;
22
23pub struct CommandHandler<T>(pub T);
24
25impl<T> CommandHandler<T> {
26 pub fn destruct(self) -> T {
27 self.0
28 }
29}
30
31pub trait AsyncFunc<C, R, ApplicationResult>: Fn(C, R) -> Self::Fut + Send + Sync {
32 type Fut: std::future::Future<Output = ApplicationResult> + Send;
33}
34
35impl<F, C, Fut, Respository, ApplicationResult> AsyncFunc<C, Respository, ApplicationResult> for F
36where
37 C: crate::prelude::TCommand,
38 F: Fn(C, Respository) -> Fut + Send + Sync,
39 Fut: std::future::Future<Output = ApplicationResult> + Send,
40{
41 type Fut = Fut;
42}
43
44pub trait TGetHandler<R, ApplicationResult>: Sized {
45 fn get_handler() -> impl AsyncFunc<Self, R, ApplicationResult>;
46}