1
1
use std:: future:: Future ;
2
2
3
3
use ntex:: connect:: { self , Address , Connect , Connector } ;
4
- use ntex:: io:: { Io , IoBoxed } ;
4
+ use ntex:: io:: { Filter , Io , IoBoxed } ;
5
5
use ntex:: { service:: Service , time:: Seconds , util:: ByteString , util:: PoolId , util:: PoolRef } ;
6
6
7
7
#[ cfg( feature = "openssl" ) ]
8
- use ntex:: connect:: openssl:: { OpensslConnector , SslConnector } ;
8
+ use ntex:: connect:: openssl:: { self , SslConnector } ;
9
9
10
10
#[ cfg( feature = "rustls" ) ]
11
- use ntex:: connect:: rustls:: { ClientConfig , RustlsConnector } ;
11
+ use ntex:: connect:: rustls:: { self , ClientConfig } ;
12
12
13
13
use super :: errors:: ConnectError ;
14
14
use super :: { cmd, Client , SimpleClient } ;
@@ -27,11 +27,16 @@ where
27
27
{
28
28
#[ allow( clippy:: new_ret_no_self) ]
29
29
/// Create new redis connector
30
- pub fn new ( address : A ) -> RedisConnector < A , Connector < A > > {
30
+ pub fn new (
31
+ address : A ,
32
+ ) -> RedisConnector <
33
+ A ,
34
+ impl Service < Request = Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
35
+ > {
31
36
RedisConnector {
32
37
address,
33
38
passwords : Vec :: new ( ) ,
34
- connector : Connector :: default ( ) ,
39
+ connector : Connector :: default ( ) . map ( |io| io . into_boxed ( ) ) ,
35
40
pool : PoolId :: P7 . pool_ref ( ) ,
36
41
}
37
42
}
@@ -62,12 +67,19 @@ where
62
67
}
63
68
64
69
/// Use custom connector
65
- pub fn connector < U , F > ( self , connector : U ) -> RedisConnector < A , U >
70
+ pub fn connector < U , F > (
71
+ self ,
72
+ connector : U ,
73
+ ) -> RedisConnector <
74
+ A ,
75
+ impl Service < Request = Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
76
+ >
66
77
where
78
+ F : Filter ,
67
79
U : Service < Request = Connect < A > , Response = Io < F > , Error = connect:: ConnectError > ,
68
80
{
69
81
RedisConnector {
70
- connector,
82
+ connector : connector . map ( |io| io . into_boxed ( ) ) ,
71
83
address : self . address ,
72
84
passwords : self . passwords ,
73
85
pool : self . pool ,
@@ -76,11 +88,17 @@ where
76
88
77
89
#[ cfg( feature = "openssl" ) ]
78
90
/// Use openssl connector.
79
- pub fn openssl ( self , connector : SslConnector ) -> RedisConnector < A , OpensslConnector < A > > {
91
+ pub fn openssl (
92
+ self ,
93
+ connector : SslConnector ,
94
+ ) -> RedisConnector <
95
+ A ,
96
+ impl Service < Request = Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
97
+ > {
80
98
RedisConnector {
81
99
address : self . address ,
82
100
passwords : self . passwords ,
83
- connector : OpensslConnector :: new ( connector) ,
101
+ connector : openssl :: Connector :: new ( connector) . map ( |io| io . into_boxed ( ) ) ,
84
102
pool : self . pool ,
85
103
}
86
104
}
@@ -89,12 +107,15 @@ where
89
107
/// Use rustls connector.
90
108
pub fn rustls (
91
109
self ,
92
- config : std:: sync:: Arc < ClientConfig > ,
93
- ) -> RedisConnector < A , RustlsConnector < A > > {
110
+ config : ClientConfig ,
111
+ ) -> RedisConnector <
112
+ A ,
113
+ impl Service < Request = Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
114
+ > {
94
115
RedisConnector {
95
116
address : self . address ,
96
117
passwords : self . passwords ,
97
- connector : RustlsConnector :: new ( config) ,
118
+ connector : rustls :: Connector :: new ( config) . map ( |io| io . into_boxed ( ) ) ,
98
119
pool : self . pool ,
99
120
}
100
121
}
0 commit comments