pub struct MessageBus<R, E>where
R: ApplicationResponse,
E: ApplicationError,{ /* private fields */ }Implementations§
Source§impl<R, E> MessageBus<R, E>where
R: ApplicationResponse + Send,
E: ApplicationError + From<BaseError> + Into<BaseError> + Send,
impl<R, E> MessageBus<R, E>where
R: ApplicationResponse + Send,
E: ApplicationError + From<BaseError> + Into<BaseError> + Send,
pub fn new( command_handler: &'static HashMap<TypeId, Box<dyn Fn(Box<dyn Any + Sync + Send>, Arc<RwLock<ContextManager>>) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send>> + Sync + Send>>, event_handler: &'static HashMap<String, Vec<Box<dyn Fn(Box<dyn Message>, Arc<RwLock<ContextManager>>) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send>> + Sync + Send>>>, ) -> Arc<MessageBus<R, E>>
pub async fn handle<C>(&self, message: C) -> Result<R, E>where
C: Command,
pub async fn handle_event(&self, msg: Box<dyn Message>) -> Result<(), E>
Auto Trait Implementations§
impl<R, E> Freeze for MessageBus<R, E>
impl<R, E> !RefUnwindSafe for MessageBus<R, E>
impl<R, E> Send for MessageBus<R, E>
impl<R, E> Sync for MessageBus<R, E>
impl<R, E> Unpin for MessageBus<R, E>
impl<R, E> !UnwindSafe for MessageBus<R, E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.