general_mq::queue

Trait GmqQueue

Source
pub trait GmqQueue: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn is_recv(&self) -> bool;
    fn status(&self) -> Status;
    fn set_handler(&mut self, handler: Arc<dyn EventHandler>);
    fn clear_handler(&mut self);
    fn set_msg_handler(&mut self, handler: Arc<dyn MessageHandler>);
    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;
    fn send_msg<'life0, 'async_trait>(
        &'life0 self,
        payload: Vec<u8>,
    ) -> 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 queues.

Required Methods§

Source

fn name(&self) -> &str

To get the queue name.

Source

fn is_recv(&self) -> bool

Is the queue a receiver.

Source

fn status(&self) -> Status

To get the connection status.

Source

fn set_handler(&mut self, handler: Arc<dyn EventHandler>)

To set the queue event handler.

Source

fn clear_handler(&mut self)

To remove the queue event handler.

Source

fn set_msg_handler(&mut self, handler: Arc<dyn MessageHandler>)

To set the queue message handler.

Source

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

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

Note You MUST call set_msg_handler() before connect().

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 queue.

Source

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

To send a message (for senders only).

Implementors§