From a34a4accaf1c1ed7fab926daddb7e83b98e5cf4d Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Mon, 27 Apr 2020 22:12:31 +0200 Subject: [PATCH] make amqp error type generic --- ofborg/src/easyamqp.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ofborg/src/easyamqp.rs b/ofborg/src/easyamqp.rs index 02f13a8..23b616b 100644 --- a/ofborg/src/easyamqp.rs +++ b/ofborg/src/easyamqp.rs @@ -297,28 +297,32 @@ pub fn session_from_config(config: &RabbitMQConfig) -> Result(&mut self, callback: T, config: ConsumeConfig) -> Result + type Error; + + fn consume(&mut self, callback: T, config: ConsumeConfig) -> Result where T: amqp::Consumer + 'static; fn declare_exchange( &mut self, config: ExchangeConfig, - ) -> Result; + ) -> Result; fn declare_queue( &mut self, config: QueueConfig, - ) -> Result; + ) -> Result; fn bind_queue( &mut self, config: BindQueueConfig, - ) -> Result; + ) -> Result; } impl TypedWrappers for amqp::Channel { - fn consume(&mut self, callback: T, config: ConsumeConfig) -> Result + type Error = amqp::AMQPError; + + fn consume(&mut self, callback: T, config: ConsumeConfig) -> Result where T: amqp::Consumer + 'static, { @@ -337,7 +341,7 @@ impl TypedWrappers for amqp::Channel { fn declare_exchange( &mut self, config: ExchangeConfig, - ) -> Result { + ) -> Result { self.exchange_declare( config.exchange, config.exchange_type.into(), @@ -353,7 +357,7 @@ impl TypedWrappers for amqp::Channel { fn declare_queue( &mut self, config: QueueConfig, - ) -> Result { + ) -> Result { self.queue_declare( config.queue, config.passive, @@ -368,7 +372,7 @@ impl TypedWrappers for amqp::Channel { fn bind_queue( &mut self, config: BindQueueConfig, - ) -> Result { + ) -> Result { self.queue_bind( config.queue, config.exchange,