@@ -24,6 +24,9 @@ pub struct StatementMetaWriter<W> {
24
24
pub ( crate ) stmts : HashMap < u32 , StatementData > ,
25
25
}
26
26
27
+ existential type ReplyFut < W > :
28
+ Future < Item = PartialServiceState < W , MissingService > , Error = io:: Error > ;
29
+
27
30
impl < W : AsyncWrite > StatementMetaWriter < W > {
28
31
/// Reply to the client with the given meta-information.
29
32
///
@@ -32,18 +35,12 @@ impl<W: AsyncWrite> StatementMetaWriter<W> {
32
35
/// parameters the client must provide when executing the prepared statement. `columns` is a
33
36
/// second set of [`Column`](struct.Column.html) descriptors for the values that will be
34
37
/// returned in each row then the statement is later executed.
35
- pub fn reply < ' a , PI , CI > (
36
- mut self ,
37
- id : u32 ,
38
- params : PI ,
39
- columns : CI ,
40
- ) -> impl Future < Item = PartialServiceState < W , MissingService > , Error = io:: Error > + ' static
38
+ pub fn reply < ' a , PI , CI > ( mut self , id : u32 , params : PI , columns : CI ) -> ReplyFut < W >
41
39
where
42
40
PI : IntoIterator < Item = & ' a Column > ,
43
41
CI : IntoIterator < Item = & ' a Column > ,
44
42
<PI as IntoIterator >:: IntoIter : ExactSizeIterator ,
45
43
<CI as IntoIterator >:: IntoIter : ExactSizeIterator ,
46
- W : ' static ,
47
44
{
48
45
let params = params. into_iter ( ) ;
49
46
self . stmts . insert (
@@ -54,9 +51,10 @@ impl<W: AsyncWrite> StatementMetaWriter<W> {
54
51
} ,
55
52
) ;
56
53
57
- writers:: write_prepare_ok ( id, params, columns, & mut self . writer )
58
- . into_future ( )
59
- . and_then ( move |_| self . writer . flusher ( self . stmts ) )
54
+ match writers:: write_prepare_ok ( id, params, columns, & mut self . writer ) {
55
+ Ok ( _) => future:: Either :: A ( self . writer . flusher ( self . stmts ) ) ,
56
+ Err ( e) => future:: Either :: B ( future:: err ( e) ) ,
57
+ }
60
58
}
61
59
62
60
/// Reply to the client's `PREPARE` with an error.
@@ -453,25 +451,25 @@ impl<'a, W: Write, M> RowWriter<'a, W, M> {
453
451
}
454
452
}
455
453
454
+ existential type FinishFut < W , M > : Future < Item = PartialServiceState < W , M > , Error = io:: Error > ;
455
+ existential type FinishOneFut < W , M > : Future < Item = QueryResultWriter < W , M > , Error = io:: Error > ;
456
+
456
457
impl < ' a , W : AsyncWrite + ' static , M : PartialMissing > RowWriter < ' a , W , M > {
457
458
/// Indicate to the client that no more rows are coming.
458
- pub fn finish (
459
- self ,
460
- ) -> impl Future < Item = PartialServiceState < W , M > , Error = io:: Error > + ' static {
459
+ pub fn finish ( self ) -> FinishFut < W , M > {
461
460
self . finish_one ( ) . and_then ( |w| w. no_more_results ( ) )
462
461
}
463
462
464
463
/// End this resultset response, and indicate to the client that no more rows are coming.
465
- pub fn finish_one (
466
- mut self ,
467
- ) -> impl Future < Item = QueryResultWriter < W , M > , Error = io:: Error > + ' static {
468
- let r = self . finish_inner ( ) ;
469
- let pw = self . result . take ( ) . unwrap ( ) ;
470
- r. into_future ( ) . and_then ( move |_| {
471
- // we know that dropping self will see self.finished == true,
472
- // and so Drop won't try to use self.result.
473
- pw. flush ( )
474
- } )
464
+ pub fn finish_one ( mut self ) -> FinishOneFut < W , M > {
465
+ match self . finish_inner ( ) {
466
+ Ok ( _) => {
467
+ // we know that dropping self will see self.finished == true,
468
+ // and so Drop won't try to use self.result.
469
+ future:: Either :: A ( self . result . take ( ) . unwrap ( ) . flush ( ) )
470
+ }
471
+ Err ( e) => future:: Either :: B ( future:: err ( e) ) ,
472
+ }
475
473
}
476
474
}
477
475
0 commit comments