@@ -298,14 +298,7 @@ where
298
298
self . parameters . get ( name) . map ( |s|& * * s)
299
299
}
300
300
301
- /// Polls for asynchronous messages from the server.
302
- ///
303
- /// The server can send notices as well as notifications asynchronously to the client. Applications that wish to
304
- /// examine those messages should use this method to drive the connection rather than its `Future` implementation.
305
- ///
306
- /// Return values of `None` or `Some(Err(_))` are "terminal"; callers should not invoke this method again after
307
- /// receiving one of those values.
308
- pub fn poll_message (
301
+ fn poll_message_inner (
309
302
& mut self ,
310
303
cx : & mut Context < ' _ > ,
311
304
) ->Poll < Option < Result < AsyncMessage , Error > > > {
@@ -323,6 +316,26 @@ where
323
316
} ,
324
317
}
325
318
}
319
+
320
+ /// Polls for asynchronous messages from the server.
321
+ ///
322
+ /// The server can send notices as well as notifications asynchronously to the client. Applications that wish to
323
+ /// examine those messages should use this method to drive the connection rather than its `Future` implementation.
324
+ ///
325
+ /// Return values of `None` or `Some(Err(_))` are "terminal"; callers should not invoke this method again after
326
+ /// receiving one of those values.
327
+ pub fn poll_message (
328
+ & mut self ,
329
+ cx : & mut Context < ' _ > ,
330
+ ) ->Poll < Option < Result < AsyncMessage , Error > > > {
331
+ match self . poll_message_inner ( cx) {
332
+ nominal @( Poll :: Pending |Poll :: Ready ( Some ( Ok ( _) ) ) ) => nominal,
333
+ terminal @( Poll :: Ready ( None ) |Poll :: Ready ( Some ( Err ( _) ) ) ) =>{
334
+ self . receiver . close ( ) ;
335
+ terminal
336
+ }
337
+ }
338
+ }
326
339
}
327
340
328
341
impl < S , T > Future for Connection < S , T >