@@ -2,19 +2,19 @@ use crate::types::RedisBytes;
2
2
use crate :: types:: { RsmqMessage , RsmqQueueAttributes } ;
3
3
use crate :: RsmqResult ;
4
4
use core:: convert:: TryFrom ;
5
+ use std:: future:: Future ;
5
6
use std:: time:: Duration ;
6
7
7
- #[ async_trait:: async_trait]
8
8
pub trait RsmqConnection {
9
9
/// Change the hidden time of a already sent message.
10
10
///
11
11
/// `hidden` has a max time of 9_999_999 for compatibility reasons to this library JS version counterpart
12
- async fn change_message_visibility (
12
+ fn change_message_visibility (
13
13
& mut self ,
14
14
qname : & str ,
15
15
message_id : & str ,
16
16
hidden : Duration ,
17
- ) -> RsmqResult < ( ) > ;
17
+ ) -> impl Future < Output = RsmqResult < ( ) > > + Send ;
18
18
19
19
/// Creates a new queue. Attributes can be later modified with "set_queue_attributes" method
20
20
///
@@ -25,53 +25,60 @@ pub trait RsmqConnection {
25
25
///
26
26
/// maxsize: Maximum size in bytes of each message in the queue. Needs to be between 1024 or 65536 or -1 (unlimited
27
27
/// size)
28
- async fn create_queue (
28
+ fn create_queue (
29
29
& mut self ,
30
30
qname : & str ,
31
31
hidden : Option < Duration > ,
32
32
delay : Option < Duration > ,
33
33
maxsize : Option < i32 > ,
34
- ) -> RsmqResult < ( ) > ;
34
+ ) -> impl Future < Output = RsmqResult < ( ) > > + Send ;
35
35
36
36
/// Deletes a message from the queue.
37
37
///
38
38
/// Important to use when you are using receive_message.
39
- async fn delete_message ( & mut self , qname : & str , id : & str ) -> RsmqResult < bool > ;
39
+ fn delete_message (
40
+ & mut self ,
41
+ qname : & str ,
42
+ id : & str ,
43
+ ) -> impl Future < Output = RsmqResult < bool > > + Send ;
40
44
41
45
/// Deletes the queue and all the messages on it
42
- async fn delete_queue ( & mut self , qname : & str ) -> RsmqResult < ( ) > ;
46
+ fn delete_queue ( & mut self , qname : & str ) -> impl Future < Output = RsmqResult < ( ) > > + Send ;
43
47
44
48
/// Returns the queue attributes and statistics
45
- async fn get_queue_attributes ( & mut self , qname : & str ) -> RsmqResult < RsmqQueueAttributes > ;
49
+ fn get_queue_attributes (
50
+ & mut self ,
51
+ qname : & str ,
52
+ ) -> impl Future < Output = RsmqResult < RsmqQueueAttributes > > + Send ;
46
53
47
54
/// Returns a list of queues in the namespace
48
- async fn list_queues ( & mut self ) -> RsmqResult < Vec < String > > ;
55
+ fn list_queues ( & mut self ) -> impl Future < Output = RsmqResult < Vec < String > > > + Send ;
49
56
50
57
/// Deletes and returns a message. Be aware that using this you may end with deleted & unprocessed messages.
51
- async fn pop_message < E : TryFrom < RedisBytes , Error = Vec < u8 > > > (
58
+ fn pop_message < E : TryFrom < RedisBytes , Error = Vec < u8 > > > (
52
59
& mut self ,
53
60
qname : & str ,
54
- ) -> RsmqResult < Option < RsmqMessage < E > > > ;
61
+ ) -> impl Future < Output = RsmqResult < Option < RsmqMessage < E > > > > + Send ;
55
62
56
63
/// Returns a message. The message stays hidden for some time (defined by "hidden" argument or the queue
57
64
/// settings). After that time, the message will be redelivered. In order to avoid the redelivery, you need to use
58
65
/// the "delete_message" after this function.
59
66
///
60
67
/// `hidden` has a max time of 9_999_999 for compatibility reasons to this library JS version counterpart.
61
- async fn receive_message < E : TryFrom < RedisBytes , Error = Vec < u8 > > > (
68
+ fn receive_message < E : TryFrom < RedisBytes , Error = Vec < u8 > > > (
62
69
& mut self ,
63
70
qname : & str ,
64
71
hidden : Option < Duration > ,
65
- ) -> RsmqResult < Option < RsmqMessage < E > > > ;
72
+ ) -> impl Future < Output = RsmqResult < Option < RsmqMessage < E > > > > + Send ;
66
73
67
74
/// Sends a message to the queue. The message will be delayed some time (controlled by the "delayed" argument or
68
75
/// the queue settings) before being delivered to a client.
69
- async fn send_message < E : Into < RedisBytes > + Send > (
76
+ fn send_message < E : Into < RedisBytes > + Send > (
70
77
& mut self ,
71
78
qname : & str ,
72
79
message : E ,
73
80
delay : Option < Duration > ,
74
- ) -> RsmqResult < String > ;
81
+ ) -> impl Future < Output = RsmqResult < String > > + Send ;
75
82
76
83
/// Modify the queue attributes. Keep in mind that "hidden" and "delay" can be overwritten when the message
77
84
/// is sent. "hidden" can be changed by the method "change_message_visibility"
@@ -83,11 +90,11 @@ pub trait RsmqConnection {
83
90
///
84
91
/// maxsize: Maximum size in bytes of each message in the queue. Needs to be between 1024 or 65536 or -1 (unlimited
85
92
/// size)
86
- async fn set_queue_attributes (
93
+ fn set_queue_attributes (
87
94
& mut self ,
88
95
qname : & str ,
89
96
hidden : Option < Duration > ,
90
97
delay : Option < Duration > ,
91
98
maxsize : Option < i64 > ,
92
- ) -> RsmqResult < RsmqQueueAttributes > ;
99
+ ) -> impl Future < Output = RsmqResult < RsmqQueueAttributes > > + Send ;
93
100
}
0 commit comments