@@ -145,13 +145,11 @@ where
145
145
IoBoxed : From < T :: Response > ,
146
146
{
147
147
/// Connect to amqp server
148
- pub fn connect ( & self , address : A ) -> impl Future < Output = Result < Client , ConnectError > > {
148
+ pub async fn connect ( & self , address : A ) -> Result < Client , ConnectError > {
149
149
let fut = timeout_checked ( self . handshake_timeout , self . _connect ( address) ) ;
150
- async move {
151
- match fut. await {
152
- Ok ( res) => res. map_err ( From :: from) ,
153
- Err ( _) => Err ( ConnectError :: HandshakeTimeout ) ,
154
- }
150
+ match fut. await {
151
+ Ok ( res) => res. map_err ( From :: from) ,
152
+ Err ( _) => Err ( ConnectError :: HandshakeTimeout ) ,
155
153
}
156
154
}
157
155
@@ -165,35 +163,27 @@ where
165
163
_connect_plain ( io, self . config . clone ( ) )
166
164
}
167
165
168
- fn _connect ( & self , address : A ) -> impl Future < Output = Result < Client , ConnectError > > {
169
- let fut = self . connector . call ( Connect :: new ( address) ) ;
166
+ async fn _connect ( & self , address : A ) -> Result < Client , ConnectError > {
167
+ let io = self . connector . call ( Connect :: new ( address) ) . await ? ;
170
168
let config = self . config . clone ( ) ;
171
169
let pool = self . pool ;
172
170
let disconnect = self . disconnect_timeout ;
173
171
174
- async move {
175
- trace ! ( "Negotiation client protocol id: Amqp" ) ;
172
+ trace ! ( "Negotiation client protocol id: Amqp" ) ;
176
173
177
- let io = IoBoxed :: from ( fut . await ? ) ;
178
- io. set_memory_pool ( pool) ;
179
- io. set_disconnect_timeout ( disconnect. into ( ) ) ;
174
+ let io = IoBoxed :: from ( io ) ;
175
+ io. set_memory_pool ( pool) ;
176
+ io. set_disconnect_timeout ( disconnect. into ( ) ) ;
180
177
181
- _connect_plain ( io, config) . await
182
- }
178
+ _connect_plain ( io, config) . await
183
179
}
184
180
185
181
/// Connect to amqp server
186
- pub fn connect_sasl (
187
- & self ,
188
- addr : A ,
189
- auth : SaslAuth ,
190
- ) -> impl Future < Output = Result < Client , ConnectError > > {
182
+ pub async fn connect_sasl ( & self , addr : A , auth : SaslAuth ) -> Result < Client , ConnectError > {
191
183
let fut = timeout_checked ( self . handshake_timeout , self . _connect_sasl ( addr, auth) ) ;
192
- async move {
193
- match fut. await {
194
- Ok ( res) => res. map_err ( From :: from) ,
195
- Err ( _) => Err ( ConnectError :: HandshakeTimeout ) ,
196
- }
184
+ match fut. await {
185
+ Ok ( res) => res. map_err ( From :: from) ,
186
+ Err ( _) => Err ( ConnectError :: HandshakeTimeout ) ,
197
187
}
198
188
}
199
189
@@ -212,23 +202,17 @@ where
212
202
_connect_sasl ( io, auth, config)
213
203
}
214
204
215
- fn _connect_sasl (
216
- & self ,
217
- addr : A ,
218
- auth : SaslAuth ,
219
- ) -> impl Future < Output = Result < Client , ConnectError > > {
220
- let fut = self . connector . call ( Connect :: new ( addr) ) ;
205
+ async fn _connect_sasl ( & self , addr : A , auth : SaslAuth ) -> Result < Client , ConnectError > {
206
+ let io = self . connector . call ( Connect :: new ( addr) ) . await ?;
221
207
let config = self . config . clone ( ) ;
222
208
let pool = self . pool ;
223
209
let disconnect = self . disconnect_timeout ;
224
210
225
- async move {
226
- let io = IoBoxed :: from ( fut. await ?) ;
227
- io. set_memory_pool ( pool) ;
228
- io. set_disconnect_timeout ( disconnect. into ( ) ) ;
211
+ let io = IoBoxed :: from ( io) ;
212
+ io. set_memory_pool ( pool) ;
213
+ io. set_disconnect_timeout ( disconnect. into ( ) ) ;
229
214
230
- _connect_sasl ( io, auth, config) . await
231
- }
215
+ _connect_sasl ( io, auth, config) . await
232
216
}
233
217
}
234
218
0 commit comments