@@ -115,34 +115,34 @@ cfg_async!(
115115 }
116116 }
117117 impl_async_methods!( Connection ) ;
118+ ) ;
118119
119- cfg_async_ssl_any!(
120- use tokio_openssl:: SslStream ;
121- use openssl:: ssl:: { SslContext , SslMethod , Ssl } ;
122- use core:: pin:: Pin ;
123- use crate :: error:: SslError ;
120+ cfg_async_ssl_any ! (
121+ use tokio_openssl:: SslStream ;
122+ use openssl:: ssl:: { SslContext , SslMethod , Ssl } ;
123+ use core:: pin:: Pin ;
124+ use crate :: error:: SslError ;
124125
125- /// An asynchronous database connection over Skyhash/TLS
126- pub struct TlsConnection {
127- stream: SslStream <TcpStream >,
128- buffer: BytesMut
129- }
126+ /// An asynchronous database connection over Skyhash/TLS
127+ pub struct TlsConnection {
128+ stream: SslStream <TcpStream >,
129+ buffer: BytesMut
130+ }
130131
131- impl TlsConnection {
132- /// Pass the `host` and `port` and the path to the CA certificate to use for TLS
133- pub async fn new( host: & str , port: u16 , sslcert: & str ) -> Result <Self , SslError > {
134- let mut ctx = SslContext :: builder( SslMethod :: tls_client( ) ) ?;
135- ctx. set_ca_file( sslcert) ?;
136- let ssl = Ssl :: new( & ctx. build( ) ) ?;
137- let stream = TcpStream :: connect( ( host, port) ) . await ?;
138- let mut stream = SslStream :: new( ssl, stream) ?;
139- Pin :: new( & mut stream) . connect( ) . await ?;
140- Ok ( Self {
141- stream,
142- buffer: BytesMut :: with_capacity( BUF_CAP ) ,
143- } )
144- }
132+ impl TlsConnection {
133+ /// Pass the `host` and `port` and the path to the CA certificate to use for TLS
134+ pub async fn new( host: & str , port: u16 , sslcert: & str ) -> Result <Self , SslError > {
135+ let mut ctx = SslContext :: builder( SslMethod :: tls_client( ) ) ?;
136+ ctx. set_ca_file( sslcert) ?;
137+ let ssl = Ssl :: new( & ctx. build( ) ) ?;
138+ let stream = TcpStream :: connect( ( host, port) ) . await ?;
139+ let mut stream = SslStream :: new( ssl, stream) ?;
140+ Pin :: new( & mut stream) . connect( ) . await ?;
141+ Ok ( Self {
142+ stream,
143+ buffer: BytesMut :: with_capacity( BUF_CAP ) ,
144+ } )
145145 }
146- impl_async_methods! ( TlsConnection ) ;
147- ) ;
146+ }
147+ impl_async_methods! ( TlsConnection ) ;
148148) ;
0 commit comments