@@ -10,7 +10,9 @@ use httparse;
1010use mio;
1111#[ cfg( feature = "ssl" ) ]
1212use openssl:: ssl:: { Error as SslError , HandshakeError as SslHandshakeError } ;
13- #[ cfg( feature = "ssl" ) ]
13+ #[ cfg( feature = "nativetls" ) ]
14+ use native_tls:: { Error as SslError , HandshakeError as SslHandshakeError } ;
15+ #[ cfg( any( feature = "ssl" , feature = "nativetls" ) ) ]
1416type HandshakeError = SslHandshakeError < mio:: tcp:: TcpStream > ;
1517
1618use communication:: Command ;
@@ -51,10 +53,10 @@ pub enum Kind {
5153 /// the queue may relieve the situation.
5254 Queue ( mio:: channel:: SendError < Command > ) ,
5355 /// Indicates a failure to perform SSL encryption.
54- #[ cfg( feature = "ssl" ) ]
56+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
5557 Ssl ( SslError ) ,
5658 /// Indicates a failure to perform SSL encryption.
57- #[ cfg( feature = "ssl" ) ]
59+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
5860 SslHandshake ( HandshakeError ) ,
5961 /// A custom error kind for use by applications. This error kind involves extra overhead
6062 /// because it will allocate the memory on the heap. The WebSocket ignores such errors by
@@ -116,9 +118,9 @@ impl StdError for Error {
116118 Kind :: Encoding ( ref err) => err. description ( ) ,
117119 Kind :: Io ( ref err) => err. description ( ) ,
118120 Kind :: Http ( _) => "Unable to parse HTTP" ,
119- #[ cfg( feature = "ssl" ) ]
121+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
120122 Kind :: Ssl ( ref err) => err. description ( ) ,
121- #[ cfg( feature = "ssl" ) ]
123+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
122124 Kind :: SslHandshake ( ref err) => err. description ( ) ,
123125 Kind :: Queue ( _) => "Unable to send signal on event loop" ,
124126 Kind :: Custom ( ref err) => err. description ( ) ,
@@ -129,9 +131,9 @@ impl StdError for Error {
129131 match self . kind {
130132 Kind :: Encoding ( ref err) => Some ( err) ,
131133 Kind :: Io ( ref err) => Some ( err) ,
132- #[ cfg( feature = "ssl" ) ]
134+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
133135 Kind :: Ssl ( ref err) => Some ( err) ,
134- #[ cfg( feature = "ssl" ) ]
136+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
135137 Kind :: SslHandshake ( ref err) => err. cause ( ) ,
136138 Kind :: Custom ( ref err) => Some ( err. as_ref ( ) ) ,
137139 _ => None ,
@@ -178,14 +180,14 @@ impl From<Utf8Error> for Error {
178180 }
179181}
180182
181- #[ cfg( feature = "ssl" ) ]
183+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
182184impl From < SslError > for Error {
183185 fn from ( err : SslError ) -> Error {
184186 Error :: new ( Kind :: Ssl ( err) , "" )
185187 }
186188}
187189
188- #[ cfg( feature = "ssl" ) ]
190+ #[ cfg( any ( feature = "ssl" , feature = "nativetls" ) ) ]
189191impl From < HandshakeError > for Error {
190192 fn from ( err : HandshakeError ) -> Error {
191193 Error :: new ( Kind :: SslHandshake ( err) , "" )
0 commit comments