@@ -27,7 +27,7 @@ type BoxedSummary = Box<ResultSummary>;
27
27
type BoxedSummary = ( ) ;
28
28
29
29
#[ cfg( feature = "unstable-bolt-protocol-impl-v2" ) ]
30
- type FinishResult = Option < ResultSummary > ;
30
+ type FinishResult = ResultSummary ;
31
31
#[ cfg( not( feature = "unstable-bolt-protocol-impl-v2" ) ) ]
32
32
type FinishResult = ( ) ;
33
33
@@ -84,7 +84,7 @@ impl DetachedRowStream {
84
84
pub enum RowItem < T = Row > {
85
85
Row ( T ) ,
86
86
#[ cfg( feature = "unstable-result-summary" ) ]
87
- Summary ( Box < ResultSummary > ) ,
87
+ Summary ( BoxedSummary ) ,
88
88
}
89
89
90
90
impl < T > RowItem < T > {
@@ -113,7 +113,7 @@ impl<T> RowItem<T> {
113
113
}
114
114
115
115
#[ cfg( feature = "unstable-result-summary" ) ]
116
- pub fn into_summary ( self ) -> Option < Box < ResultSummary > > {
116
+ pub fn into_summary ( self ) -> Option < BoxedSummary > {
117
117
match self {
118
118
RowItem :: Summary ( summary) => Some ( summary) ,
119
119
_ => None ,
@@ -125,22 +125,10 @@ impl RowStream {
125
125
/// A call to next() will return a row from an internal buffer if the buffer has any entries,
126
126
/// if the buffer is empty and the server has more rows left to consume, then a new batch of rows
127
127
/// are fetched from the server (using the fetch_size value configured see [`crate::ConfigBuilder::fetch_size`])
128
- pub async fn next ( & mut self , handle : impl TransactionHandle ) -> Result < Option < Row > > {
129
- self . next_or_summary ( handle)
130
- . await
131
- . map ( |item| item. and_then ( RowItem :: into_row) )
132
- }
133
-
134
- /// A call to next_or_summary() will return a row from an internal buffer if the buffer has any entries,
135
- /// if the buffer is empty and the server has more rows left to consume, then a new batch of rows
136
- /// are fetched from the server (using the fetch_size value configured see [`crate::ConfigBuilder::fetch_size`])
137
- pub async fn next_or_summary (
138
- & mut self ,
139
- mut handle : impl TransactionHandle ,
140
- ) -> Result < Option < RowItem > > {
128
+ pub async fn next ( & mut self , mut handle : impl TransactionHandle ) -> Result < Option < Row > > {
141
129
loop {
142
130
if let Some ( row) = self . buffer . pop_front ( ) {
143
- return Ok ( Some ( RowItem :: Row ( row) ) ) ;
131
+ return Ok ( Some ( row) ) ;
144
132
}
145
133
146
134
#[ cfg( feature = "unstable-bolt-protocol-impl-v2" ) ]
@@ -167,16 +155,13 @@ impl RowStream {
167
155
Response :: Success ( Streaming :: HasMore ) => break State :: Ready ,
168
156
Response :: Success ( Streaming :: Done ( mut s) ) => {
169
157
s. set_t_first ( self . available_after ) ;
170
- break State :: Complete ( Some ( s ) ) ;
158
+ break State :: Complete ( s ) ;
171
159
}
172
160
otherwise => return Err ( otherwise. into_error ( "PULL" ) ) ,
173
161
}
174
162
} ;
175
- } else if let State :: Complete ( ref mut summary) = self . state {
176
- break match summary. take ( ) {
177
- Some ( summary) => Ok ( Some ( RowItem :: Summary ( summary) ) ) ,
178
- None => Ok ( None ) ,
179
- } ;
163
+ } else if let State :: Complete ( _) = self . state {
164
+ break Ok ( None ) ;
180
165
}
181
166
}
182
167
@@ -227,25 +212,21 @@ impl RowStream {
227
212
} ?;
228
213
let summary = match summary {
229
214
Summary :: Success ( s) => match s. metadata {
230
- Streaming :: Done ( summary) => Some ( * summary) ,
215
+ Streaming :: Done ( summary) => * summary,
231
216
Streaming :: HasMore => {
232
- // this should never happen
233
- None
217
+ unreachable ! ( "Query returned has_more after a discard_all" ) ;
234
218
}
235
219
} ,
236
220
Summary :: Ignored => {
237
- self . state = State :: Complete ( None ) ;
238
221
return Err ( Error :: RequestIgnoredError ) ;
239
222
}
240
223
Summary :: Failure ( f) => {
241
- self . state = State :: Complete ( None ) ;
242
224
return Err ( f. into_error ( ) ) ;
243
225
}
244
226
} ;
245
- self . state = State :: Complete ( None ) ;
246
227
Ok ( summary)
247
228
}
248
- State :: Complete ( summary) => Ok ( summary . map ( |o| * o ) ) ,
229
+ State :: Complete ( summary) => Ok ( * summary ) ,
249
230
}
250
231
251
232
#[ cfg( not( feature = "unstable-bolt-protocol-impl-v2" ) ) ]
@@ -282,17 +263,6 @@ impl RowStream {
282
263
self . convert_rows ( handle, Ok )
283
264
}
284
265
285
- /// Turns this RowStream into a [`futures::stream::TryStream`] where
286
- /// every element is a [`RowItem`].
287
- ///
288
- /// The stream can only be converted once.
289
- pub fn as_row_items < ' this , ' db : ' this > (
290
- & ' this mut self ,
291
- handle : impl TransactionHandle + ' db ,
292
- ) -> impl TryStream < Ok = RowItem , Error = Error > + ' this {
293
- self . convert_with_summary ( handle, Ok )
294
- }
295
-
296
266
/// Turns this RowStream into a [`futures::stream::TryStream`] where
297
267
/// every row is converted into a `T` by calling [`crate::row::Row::to`].
298
268
///
@@ -306,17 +276,6 @@ impl RowStream {
306
276
self . convert_rows ( handle, |row| row. to :: < T > ( ) )
307
277
}
308
278
309
- /// Turns this RowStream into a [`futures::stream::TryStream`] where
310
- /// every row is converted into a [`RowItem<T>`] by calling [`crate::row::Row::to`].
311
- ///
312
- /// The stream can only be converted once.
313
- pub fn as_items < ' this , ' db : ' this , T : DeserializeOwned + ' this > (
314
- & ' this mut self ,
315
- handle : impl TransactionHandle + ' db ,
316
- ) -> impl TryStream < Ok = RowItem < T > , Error = Error > + ' this {
317
- self . convert_with_summary ( handle, |row| row. to :: < T > ( ) )
318
- }
319
-
320
279
/// Turns this RowStream into a [`futures::stream::TryStream`] where
321
280
/// the value at the given column is converted into a `T`
322
281
/// by calling [`crate::row::Row::get`].
@@ -331,58 +290,18 @@ impl RowStream {
331
290
self . convert_rows ( handle, move |row| row. get :: < T > ( column) )
332
291
}
333
292
334
- /// Turns this RowStream into a [`futures::stream::TryStream`] where
335
- /// the value at the given column is converted into a [`RowItem<T>`]
336
- /// by calling [`crate::row::Row::get`].
337
- ///
338
- /// The stream can only be converted once.
339
- pub fn column_to_items < ' this , ' db : ' this , T : DeserializeOwned + ' db > (
340
- & ' this mut self ,
341
- handle : impl TransactionHandle + ' db ,
342
- column : & ' db str ,
343
- ) -> impl TryStream < Ok = RowItem < T > , Error = Error > + ' this {
344
- self . convert_with_summary ( handle, move |row| row. get :: < T > ( column) )
345
- }
346
-
347
293
fn convert_rows < ' this , ' db : ' this , T : ' this > (
348
294
& ' this mut self ,
349
295
handle : impl TransactionHandle + ' db ,
350
296
convert : impl Fn ( Row ) -> Result < T , DeError > + ' this ,
351
297
) -> impl TryStream < Ok = T , Error = Error > + ' this {
352
298
try_unfold ( ( self , handle, convert) , |( stream, mut hd, de) | async move {
353
- match stream. next_or_summary ( & mut hd) . await {
354
- Ok ( Some ( RowItem :: Row ( row) ) ) => match de ( row) {
299
+ match stream. next ( & mut hd) . await ? {
300
+ Some ( row) => match de ( row) {
355
301
Ok ( res) => Ok ( Some ( ( res, ( stream, hd, de) ) ) ) ,
356
302
Err ( e) => Err ( Error :: DeserializationError ( e) ) ,
357
303
} ,
358
- #[ cfg( feature = "unstable-result-summary" ) ]
359
- Ok ( Some ( RowItem :: Summary ( summary) ) ) => {
360
- stream. state = State :: Complete ( Some ( summary) ) ;
361
- Ok ( None )
362
- }
363
- Ok ( None ) => Ok ( None ) ,
364
- Err ( e) => Err ( e) ,
365
- }
366
- } )
367
- }
368
-
369
- fn convert_with_summary < ' this , ' db : ' this , T > (
370
- & ' this mut self ,
371
- handle : impl TransactionHandle + ' db ,
372
- convert : impl Fn ( Row ) -> Result < T , DeError > + ' this ,
373
- ) -> impl TryStream < Ok = RowItem < T > , Error = Error > + ' this {
374
- try_unfold ( ( self , handle, convert) , |( stream, mut hd, de) | async move {
375
- match stream. next_or_summary ( & mut hd) . await {
376
- Ok ( Some ( RowItem :: Row ( row) ) ) => match de ( row) {
377
- Ok ( res) => Ok ( Some ( ( RowItem :: Row ( res) , ( stream, hd, de) ) ) ) ,
378
- Err ( e) => Err ( Error :: DeserializationError ( e) ) ,
379
- } ,
380
- #[ cfg( feature = "unstable-result-summary" ) ]
381
- Ok ( Some ( RowItem :: Summary ( summary) ) ) => {
382
- Ok ( Some ( ( RowItem :: Summary ( summary) , ( stream, hd, de) ) ) )
383
- }
384
- Ok ( None ) => Ok ( None ) ,
385
- Err ( e) => Err ( e) ,
304
+ None => Ok ( None ) ,
386
305
}
387
306
} )
388
307
}
@@ -396,13 +315,6 @@ impl DetachedRowStream {
396
315
self . stream . next ( & mut self . connection ) . await
397
316
}
398
317
399
- /// A call to next_or_summary() will return a row from an internal buffer if the buffer has any entries,
400
- /// if the buffer is empty and the server has more rows left to consume, then a new batch of rows
401
- /// are fetched from the server (using the fetch_size value configured see [`crate::ConfigBuilder::fetch_size`])
402
- pub async fn next_or_summary ( & mut self ) -> Result < Option < RowItem > > {
403
- self . stream . next_or_summary ( & mut self . connection ) . await
404
- }
405
-
406
318
/// Stop consuming the stream and return a summary, if available.
407
319
/// Stopping the stream will also discard any messages on the server side.
408
320
pub async fn finish ( mut self ) -> Result < FinishResult > {
@@ -419,14 +331,6 @@ impl DetachedRowStream {
419
331
self . stream . into_stream ( & mut self . connection )
420
332
}
421
333
422
- /// Turns this RowStream into a [`futures::stream::TryStream`] where
423
- /// every element is a [`RowItem`].
424
- ///
425
- /// The stream can only be converted once.
426
- pub fn as_row_items ( & mut self ) -> impl TryStream < Ok = RowItem , Error = Error > + ' _ {
427
- self . stream . as_row_items ( & mut self . connection )
428
- }
429
-
430
334
/// Turns this RowStream into a [`futures::stream::TryStream`] where
431
335
/// every row is converted into a `T` by calling [`crate::row::Row::to`].
432
336
///
@@ -439,16 +343,6 @@ impl DetachedRowStream {
439
343
self . stream . into_stream_as ( & mut self . connection )
440
344
}
441
345
442
- /// Turns this RowStream into a [`futures::stream::TryStream`] where
443
- /// every row is converted into a [`RowItem<T>`] by calling [`crate::row::Row::to`].
444
- ///
445
- /// The stream can only be converted once.
446
- pub fn as_items < ' this , T : DeserializeOwned + ' this > (
447
- & ' this mut self ,
448
- ) -> impl TryStream < Ok = RowItem < T > , Error = Error > + ' this {
449
- self . stream . as_items ( & mut self . connection )
450
- }
451
-
452
346
/// Turns this RowStream into a [`futures::stream::TryStream`] where
453
347
/// the value at the given column is converted into a `T`
454
348
/// by calling [`crate::row::Row::get`].
@@ -461,22 +355,10 @@ impl DetachedRowStream {
461
355
) -> impl TryStream < Ok = T , Error = Error > + ' this {
462
356
self . stream . column_into_stream ( & mut self . connection , column)
463
357
}
464
-
465
- /// Turns this RowStream into a [`futures::stream::TryStream`] where
466
- /// the value at the given column is converted into a [`RowItem<T>`]
467
- /// by calling [`crate::row::Row::get`].
468
- ///
469
- /// The stream can only be converted once.
470
- pub fn column_to_items < ' this , ' db : ' this , T : DeserializeOwned + ' db > (
471
- & ' this mut self ,
472
- column : & ' db str ,
473
- ) -> impl TryStream < Ok = RowItem < T > , Error = Error > + ' this {
474
- self . stream . column_to_items ( & mut self . connection , column)
475
- }
476
358
}
477
359
478
360
#[ derive( Clone , PartialEq , Debug ) ]
479
361
enum State {
480
362
Ready ,
481
- Complete ( Option < BoxedSummary > ) ,
363
+ Complete ( BoxedSummary ) ,
482
364
}
0 commit comments