MessageBus

Trait MessageBus 

Source
pub trait MessageBus<M: MessageBounds>: Send + Sync {
    // Required methods
    fn publish<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 str,
        message: Arc<M>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn request_timeout(&self) -> Duration;
    fn subscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Subscription<M>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn request<'life0, 'life1, 'async_trait>(
        &'life0 self,
        topic: &'life1 str,
        message: Arc<M>,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<M>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Generic MessageBus trait

Required Methods§

Source

fn publish<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 str, message: Arc<M>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Publish a message Note async but not defined as such because this is used dynamically

Source

fn request_timeout(&self) -> Duration

Get the request_timeout

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Subscription<M>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribe to a topic on the bus

Source

fn shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Shut down

Provided Methods§

Source

fn request<'life0, 'life1, 'async_trait>( &'life0 self, topic: &'life1 str, message: Arc<M>, ) -> Pin<Box<dyn Future<Output = Result<Arc<M>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Request/response - as publish() but returns a result

Implementors§