@@ -85,35 +85,34 @@ impl Stream for SimpleQueryStream {
85
85
86
86
fn poll_next ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
87
87
let this = self . project ( ) ;
88
- loop {
89
- match ready ! ( this. responses. poll_next( cx) ?) {
90
- Message :: CommandComplete ( body) => {
91
- let rows = extract_row_affected ( & body) ?;
92
- return Poll :: Ready ( Some ( Ok ( SimpleQueryMessage :: CommandComplete ( rows) ) ) ) ;
93
- }
94
- Message :: EmptyQueryResponse => {
95
- return Poll :: Ready ( Some ( Ok ( SimpleQueryMessage :: CommandComplete ( 0 ) ) ) ) ;
96
- }
97
- Message :: RowDescription ( body) => {
98
- let columns = body
99
- . fields ( )
100
- . map ( |f| Ok ( SimpleColumn :: new ( f. name ( ) . to_string ( ) ) ) )
101
- . collect :: < Vec < _ > > ( )
102
- . map_err ( Error :: parse) ?
103
- . into ( ) ;
88
+ match ready ! ( this. responses. poll_next( cx) ?) {
89
+ Message :: CommandComplete ( body) => {
90
+ let rows = extract_row_affected ( & body) ?;
91
+ Poll :: Ready ( Some ( Ok ( SimpleQueryMessage :: CommandComplete ( rows) ) ) )
92
+ }
93
+ Message :: EmptyQueryResponse => {
94
+ Poll :: Ready ( Some ( Ok ( SimpleQueryMessage :: CommandComplete ( 0 ) ) ) )
95
+ }
96
+ Message :: RowDescription ( body) => {
97
+ let columns: Arc < [ SimpleColumn ] > = body
98
+ . fields ( )
99
+ . map ( |f| Ok ( SimpleColumn :: new ( f. name ( ) . to_string ( ) ) ) )
100
+ . collect :: < Vec < _ > > ( )
101
+ . map_err ( Error :: parse) ?
102
+ . into ( ) ;
104
103
105
- * this. columns = Some ( columns) ;
106
- }
107
- Message :: DataRow ( body) => {
108
- let row = match & this. columns {
109
- Some ( columns) => SimpleQueryRow :: new ( columns. clone ( ) , body) ?,
110
- None => return Poll :: Ready ( Some ( Err ( Error :: unexpected_message ( ) ) ) ) ,
111
- } ;
112
- return Poll :: Ready ( Some ( Ok ( SimpleQueryMessage :: Row ( row) ) ) ) ;
113
- }
114
- Message :: ReadyForQuery ( _) => return Poll :: Ready ( None ) ,
115
- _ => return Poll :: Ready ( Some ( Err ( Error :: unexpected_message ( ) ) ) ) ,
104
+ * this. columns = Some ( columns. clone ( ) ) ;
105
+ Poll :: Ready ( Some ( Ok ( SimpleQueryMessage :: RowDescription ( columns) ) ) )
106
+ }
107
+ Message :: DataRow ( body) => {
108
+ let row = match & this. columns {
109
+ Some ( columns) => SimpleQueryRow :: new ( columns. clone ( ) , body) ?,
110
+ None => return Poll :: Ready ( Some ( Err ( Error :: unexpected_message ( ) ) ) ) ,
111
+ } ;
112
+ Poll :: Ready ( Some ( Ok ( SimpleQueryMessage :: Row ( row) ) ) )
116
113
}
114
+ Message :: ReadyForQuery ( _) => Poll :: Ready ( None ) ,
115
+ _ => Poll :: Ready ( Some ( Err ( Error :: unexpected_message ( ) ) ) ) ,
117
116
}
118
117
}
119
118
}
0 commit comments