general_mq::connection

Trait GmqConnection

Source
pub trait GmqConnection: Send + Sync {
    // Required methods
    fn status(&self) -> Status;
    fn add_handler(&mut self, handler: Arc<dyn EventHandler>) -> String;
    fn remove_handler(&mut self, id: &str);
    fn connect(&mut self) -> Result<(), Box<dyn StdError>>;
    fn close<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The operations for connections.

Required Methods§

Source

fn status(&self) -> Status

To get the connection status.

Source

fn add_handler(&mut self, handler: Arc<dyn EventHandler>) -> String

To add a connection event handler. This will return an identifier for applications to manage handlers.

Source

fn remove_handler(&mut self, id: &str)

To remove a handler with an idenfier from GmqConnection::add_handler.

Source

fn connect(&mut self) -> Result<(), Box<dyn StdError>>

To connect to the message broker. The GmqConnection will connect to the broker using another runtime task and report status with Statuss.

Source

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

To close the connection.

Implementors§