37
37
}
38
38
}
39
39
40
- impl < A , T > RedisConnector < A , T >
41
- where
42
- A : Address + Clone ,
43
- T : Service < Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
44
- {
40
+ impl < A , T > RedisConnector < A , T > {
45
41
/// Add redis auth password
46
42
pub fn password < U > ( mut self , password : U ) -> Self
47
43
where
@@ -62,19 +58,26 @@ where
62
58
}
63
59
64
60
/// Use custom connector
65
- pub fn connector < Io , U > (
66
- self ,
67
- connector : U ,
68
- ) -> RedisConnector <
69
- A ,
70
- impl Service < Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
71
- >
61
+ pub fn connector < Io , U > ( self , connector : U ) -> RedisConnector < A , Boxed < U , Connect < A > > >
72
62
where
73
63
U : Service < Connect < A > , Response = Io , Error = connect:: ConnectError > ,
74
64
IoBoxed : From < Io > ,
75
65
{
76
66
RedisConnector {
77
- connector : connector. map ( |io| IoBoxed :: from ( io) ) ,
67
+ connector : Boxed :: new ( connector) ,
68
+ address : self . address ,
69
+ passwords : self . passwords ,
70
+ pool : self . pool ,
71
+ }
72
+ }
73
+
74
+ /// Use custom boxed connector
75
+ pub fn boxed_connector < U > ( self , connector : U ) -> RedisConnector < A , U >
76
+ where
77
+ U : Service < Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
78
+ {
79
+ RedisConnector {
80
+ connector,
78
81
address : self . address ,
79
82
passwords : self . passwords ,
80
83
pool : self . pool ,
90
93
RedisConnector {
91
94
address : self . address ,
92
95
passwords : self . passwords ,
93
- connector : openssl:: Connector :: new ( connector) . seal ( ) ,
96
+ connector : Boxed :: new ( openssl:: Connector :: new ( connector) ) ,
94
97
pool : self . pool ,
95
98
}
96
99
}
@@ -100,18 +103,21 @@ where
100
103
pub fn rustls (
101
104
self ,
102
105
config : ClientConfig ,
103
- ) -> RedisConnector <
104
- A ,
105
- impl Service < Request = Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
106
- > {
106
+ ) -> RedisConnector < A , Boxed < rustls:: Connector < A > , Connect < A > > > {
107
107
RedisConnector {
108
108
address : self . address ,
109
109
passwords : self . passwords ,
110
- connector : rustls:: Connector :: new ( config) . map ( |io| IoBoxed :: from ( io ) ) ,
110
+ connector : Boxed :: new ( rustls:: Connector :: new ( config) ) ,
111
111
pool : self . pool ,
112
112
}
113
113
}
114
+ }
114
115
116
+ impl < A , T > RedisConnector < A , T >
117
+ where
118
+ A : Address + Clone ,
119
+ T : Service < Connect < A > , Response = IoBoxed , Error = connect:: ConnectError > ,
120
+ {
115
121
/// Connect to redis server and create shared client
116
122
pub fn connect ( & self ) -> impl Future < Output = Result < Client , ConnectError > > {
117
123
let pool = self . pool ;
0 commit comments