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