1
1
use diesel:: connection:: statement_cache:: { MaybeCached , StatementCallbackReturnType } ;
2
2
use diesel:: QueryResult ;
3
- use futures_util:: { future, FutureExt , TryFutureExt } ;
4
- use std:: future:: Future ;
3
+ use futures_core:: future:: BoxFuture ;
4
+ use futures_util:: future:: Either ;
5
+ use futures_util:: { FutureExt , TryFutureExt } ;
6
+ use std:: future:: { self , Future } ;
5
7
6
8
pub ( crate ) struct CallbackHelper < F > ( pub ( crate ) F ) ;
7
9
8
- type PrepareFuture < ' a , C , S > = future :: Either <
10
+ type PrepareFuture < ' a , C , S > = Either <
9
11
future:: Ready < QueryResult < ( MaybeCached < ' a , S > , C ) > > ,
10
- future :: BoxFuture < ' a , QueryResult < ( MaybeCached < ' a , S > , C ) > > ,
12
+ BoxFuture < ' a , QueryResult < ( MaybeCached < ' a , S > , C ) > > ,
11
13
> ;
12
14
13
15
impl < S , F , C > StatementCallbackReturnType < S , C > for CallbackHelper < F >
@@ -18,22 +20,22 @@ where
18
20
type Return < ' a > = PrepareFuture < ' a , C , S > ;
19
21
20
22
fn from_error < ' a > ( e : diesel:: result:: Error ) -> Self :: Return < ' a > {
21
- future :: Either :: Left ( future:: ready ( Err ( e) ) )
23
+ Either :: Left ( future:: ready ( Err ( e) ) )
22
24
}
23
25
24
26
fn map_to_no_cache < ' a > ( self ) -> Self :: Return < ' a >
25
27
where
26
28
Self : ' a ,
27
29
{
28
- future :: Either :: Right (
30
+ Either :: Right (
29
31
self . 0
30
32
. map_ok ( |( stmt, conn) | ( MaybeCached :: CannotCache ( stmt) , conn) )
31
33
. boxed ( ) ,
32
34
)
33
35
}
34
36
35
37
fn map_to_cache ( stmt : & mut S , conn : C ) -> Self :: Return < ' _ > {
36
- future :: Either :: Left ( future:: ready ( Ok ( ( MaybeCached :: Cached ( stmt) , conn) ) ) )
38
+ Either :: Left ( future:: ready ( Ok ( ( MaybeCached :: Cached ( stmt) , conn) ) ) )
37
39
}
38
40
39
41
fn register_cache < ' a > (
43
45
where
44
46
Self : ' a ,
45
47
{
46
- future :: Either :: Right (
48
+ Either :: Right (
47
49
self . 0
48
50
. map_ok ( |( stmt, conn) | ( MaybeCached :: Cached ( callback ( stmt) ) , conn) )
49
51
. boxed ( ) ,
0 commit comments