Commit 70a22e2 1 parent 2eb7c06 commit 70a22e2 Copy full SHA for 70a22e2
File tree 3 files changed +16
-18
lines changed
3 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,15 @@ decimal = [ "rust_decimal", "num-bigint" ]
34
34
json = [ " serde" , " serde_json" ]
35
35
36
36
# runtimes
37
- runtime-actix-native-tls = [ " sqlx-rt/runtime-actix-native-tls" , " _rt-actix" ]
38
- runtime-async-std-native-tls = [ " sqlx-rt/runtime-async-std-native-tls" , " _rt-async-std" ]
39
- runtime-tokio-native-tls = [ " sqlx-rt/runtime-tokio-native-tls" , " _rt-tokio" ]
37
+ runtime-actix-native-tls = [ " sqlx-rt/runtime-actix-native-tls" , " _tls-native-tls " , " _rt-actix" ]
38
+ runtime-async-std-native-tls = [ " sqlx-rt/runtime-async-std-native-tls" , " _tls-native-tls " , " _rt-async-std" ]
39
+ runtime-tokio-native-tls = [ " sqlx-rt/runtime-tokio-native-tls" , " _tls-native-tls " , " _rt-tokio" ]
40
40
41
41
# for conditional compilation
42
42
_rt-actix = []
43
43
_rt-async-std = []
44
44
_rt-tokio = []
45
+ _tls-native-tls = []
45
46
46
47
# support offline/decoupled building (enables serialization of `Describe`)
47
48
offline = [ " serde" , " either/serde" ]
Original file line number Diff line number Diff line change @@ -129,12 +129,6 @@ impl Error {
129
129
pub ( crate ) fn config ( err : impl StdError + Send + Sync + ' static ) -> Self {
130
130
Error :: Configuration ( err. into ( ) )
131
131
}
132
-
133
- #[ allow( dead_code) ]
134
- #[ inline]
135
- pub ( crate ) fn tls ( err : impl StdError + Send + Sync + ' static ) -> Self {
136
- Error :: Tls ( err. into ( ) )
137
- }
138
132
}
139
133
140
134
pub ( crate ) fn mismatched_types < DB : Database , T : Type < DB > > ( ty : & DB :: TypeInfo ) -> BoxDynError {
@@ -240,6 +234,14 @@ impl From<crate::migrate::MigrateError> for Error {
240
234
}
241
235
}
242
236
237
+ #[ cfg( feature = "_tls-native-tls" ) ]
238
+ impl From < sqlx_rt:: native_tls:: Error > for Error {
239
+ #[ inline]
240
+ fn from ( error : sqlx_rt:: native_tls:: Error ) -> Self {
241
+ Error :: Tls ( Box :: new ( error) )
242
+ }
243
+ }
244
+
243
245
// Format an error message as a `Protocol` error
244
246
macro_rules! err_protocol {
245
247
( $expr: expr) => {
Original file line number Diff line number Diff line change @@ -48,17 +48,17 @@ where
48
48
if !accept_invalid_certs {
49
49
if let Some ( ca) = root_cert_path {
50
50
let data = fs:: read ( ca) . await ?;
51
- let cert = Certificate :: from_pem ( & data) . map_err ( Error :: tls ) ?;
51
+ let cert = Certificate :: from_pem ( & data) ?;
52
52
53
53
builder. add_root_certificate ( cert) ;
54
54
}
55
55
}
56
56
57
57
#[ cfg( not( feature = "_rt-async-std" ) ) ]
58
- let connector = builder. build ( ) . map_err ( Error :: tls ) ? ;
58
+ let connector = sqlx_rt :: TlsConnector :: from ( builder. build ( ) ? ) ;
59
59
60
60
#[ cfg( feature = "_rt-async-std" ) ]
61
- let connector = builder;
61
+ let connector = sqlx_rt :: TlsConnector :: from ( builder) ;
62
62
63
63
let stream = match replace ( self , MaybeTlsStream :: Upgrading ) {
64
64
MaybeTlsStream :: Raw ( stream) => stream,
75
75
}
76
76
} ;
77
77
78
- * self = MaybeTlsStream :: Tls (
79
- sqlx_rt:: TlsConnector :: from ( connector)
80
- . connect ( host, stream)
81
- . await
82
- . map_err ( |err| Error :: Tls ( err. into ( ) ) ) ?,
83
- ) ;
78
+ * self = MaybeTlsStream :: Tls ( connector. connect ( host, stream) . await ?) ;
84
79
85
80
Ok ( ( ) )
86
81
}
You can’t perform that action at this time.
0 commit comments