pub trait TMessageBus<R, E, C>: TEventBus<E>where
BaseError: From<E>,
R: ApplicationResponse,
E: ApplicationError + From<BaseError>,
C: TCommand,{
// Required method
fn command_handler(
&self,
context_manager: AtomicContextManager,
cmd: C,
) -> impl TCommandService<R, E>;
// Provided methods
fn execute_and_wait<'life0, 'async_trait>(
&'life0 self,
message: C,
conn: &'static dyn TConnection,
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn execute_and_forget<'life0, 'async_trait>(
&'life0 self,
message: C,
conn: &'static dyn TConnection,
) -> Pin<Box<dyn Future<Output = Result<CommandResponseWithEventFutures<R, E>, E>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Required Methods§
fn command_handler( &self, context_manager: AtomicContextManager, cmd: C, ) -> impl TCommandService<R, E>
Provided Methods§
Sourcefn execute_and_wait<'life0, 'async_trait>(
&'life0 self,
message: C,
conn: &'static dyn TConnection,
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn execute_and_wait<'life0, 'async_trait>(
&'life0 self,
message: C,
conn: &'static dyn TConnection,
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
This method is used to handle command and return result.
§Example
let res = service.execute_and_wait(message).await?;Sourcefn execute_and_forget<'life0, 'async_trait>(
&'life0 self,
message: C,
conn: &'static dyn TConnection,
) -> Pin<Box<dyn Future<Output = Result<CommandResponseWithEventFutures<R, E>, E>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn execute_and_forget<'life0, 'async_trait>(
&'life0 self,
message: C,
conn: &'static dyn TConnection,
) -> Pin<Box<dyn Future<Output = Result<CommandResponseWithEventFutures<R, E>, E>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
This method is used to handle command and return result proxy which holds the result and join handler.
§Example
let res = service.execute_and_forget(message).await?;
let res = res.wait_until_event_processing_done().await?;
let res = res.result();Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.