@@ -4040,26 +4040,23 @@ where
40404040}
40414041
40424042impl < S : Read + Write > SslStream < S > {
4043- fn new_base ( ssl : Ssl , stream : S ) -> Self {
4044- unsafe {
4045- let ( bio, method) = bio:: new ( stream) . unwrap ( ) ;
4046- ffi:: SSL_set_bio ( ssl. as_ptr ( ) , bio, bio) ;
4047-
4048- SslStream {
4049- ssl : ManuallyDrop :: new ( ssl) ,
4050- method : ManuallyDrop :: new ( method) ,
4051- _p : PhantomData ,
4052- }
4053- }
4054- }
4055-
40564043 /// Creates a new `SslStream`.
40574044 ///
40584045 /// This function performs no IO; the stream will not have performed any part of the handshake
40594046 /// with the peer. The `connect` and `accept` methods can be used to
40604047 /// explicitly perform the handshake.
40614048 pub fn new ( ssl : Ssl , stream : S ) -> Result < Self , ErrorStack > {
4062- Ok ( Self :: new_base ( ssl, stream) )
4049+ let ( bio, method) = bio:: new ( stream) ?;
4050+
4051+ unsafe {
4052+ ffi:: SSL_set_bio ( ssl. as_ptr ( ) , bio, bio) ;
4053+ }
4054+
4055+ Ok ( SslStream {
4056+ ssl : ManuallyDrop :: new ( ssl) ,
4057+ method : ManuallyDrop :: new ( method) ,
4058+ _p : PhantomData ,
4059+ } )
40634060 }
40644061
40654062 /// Constructs an `SslStream` from a pointer to the underlying OpenSSL `SSL` struct.
@@ -4071,7 +4068,7 @@ impl<S: Read + Write> SslStream<S> {
40714068 /// The caller must ensure the pointer is valid.
40724069 pub unsafe fn from_raw_parts ( ssl : * mut ffi:: SSL , stream : S ) -> Self {
40734070 let ssl = Ssl :: from_ptr ( ssl) ;
4074- Self :: new_base ( ssl, stream)
4071+ Self :: new ( ssl, stream) . unwrap ( )
40754072 }
40764073
40774074 /// Like `read`, but takes a possibly-uninitialized slice.
@@ -4338,7 +4335,7 @@ where
43384335 /// Begin creating an `SslStream` atop `stream`
43394336 pub fn new ( ssl : Ssl , stream : S ) -> Self {
43404337 Self {
4341- inner : SslStream :: new_base ( ssl, stream) ,
4338+ inner : SslStream :: new ( ssl, stream) . unwrap ( ) ,
43424339 }
43434340 }
43444341
0 commit comments