@@ -21,12 +21,13 @@ use crate::{
21
21
use bytes:: { Buf , BytesMut } ;
22
22
use fallible_iterator:: FallibleIterator ;
23
23
use futures_channel:: mpsc;
24
- use futures_util:: { future, pin_mut, ready, StreamExt , TryStreamExt } ;
24
+ use futures_util:: { future, pin_mut, ready, Stream , StreamExt , TryStreamExt } ;
25
25
use parking_lot:: Mutex ;
26
26
use postgres_protocol:: message:: { backend:: Message , frontend} ;
27
27
use postgres_types:: BorrowToSql ;
28
28
use std:: collections:: HashMap ;
29
29
use std:: fmt;
30
+ use std:: pin:: Pin ;
30
31
use std:: sync:: Arc ;
31
32
use std:: task:: { Context , Poll } ;
32
33
#[ cfg( feature = "runtime" ) ]
@@ -59,6 +60,17 @@ impl Responses {
59
60
}
60
61
}
61
62
63
+ impl Stream for Responses {
64
+ type Item = Result < Message , Error > ;
65
+
66
+ fn poll_next ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
67
+ match ready ! ( ( * self ) . poll_next( cx) ) {
68
+ Err ( err) if err. is_closed ( ) => Poll :: Ready ( None ) ,
69
+ msg => Poll :: Ready ( Some ( msg) ) ,
70
+ }
71
+ }
72
+ }
73
+
62
74
/// A cache of type info and prepared statements for fetching type info
63
75
/// (corresponding to the queries in the [prepare](prepare) module).
64
76
#[ derive( Default ) ]
0 commit comments