File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use hyper::server::{
99 accept:: Accept ,
1010 conn:: { AddrIncoming , AddrStream } ,
1111} ;
12- use rustls:: ServerConfig ;
12+ use rustls:: { ServerConfig , ServerConnection } ;
1313use tokio:: io:: { AsyncRead , AsyncWrite , ReadBuf } ;
1414
1515mod builder;
@@ -77,6 +77,26 @@ impl TlsStream {
7777 state : State :: Handshaking ( accept) ,
7878 }
7979 }
80+
81+ /// Returns a reference to the underlying IO stream.
82+ ///
83+ /// This should always return `Some`, except if an error has already been yielded.
84+ pub fn io ( & self ) -> Option < & AddrStream > {
85+ match & self . state {
86+ State :: Handshaking ( accept) => accept. get_ref ( ) ,
87+ State :: Streaming ( stream) => Some ( stream. get_ref ( ) . 0 ) ,
88+ }
89+ }
90+
91+ /// Returns a reference to the underlying [`rustls::ServerConnection'].
92+ ///
93+ /// This will start yielding `Some` only after the handshake has completed.
94+ pub fn connection ( & self ) -> Option < & ServerConnection > {
95+ match & self . state {
96+ State :: Handshaking ( _) => None ,
97+ State :: Streaming ( stream) => Some ( stream. get_ref ( ) . 1 ) ,
98+ }
99+ }
80100}
81101
82102impl AsyncRead for TlsStream {
You can’t perform that action at this time.
0 commit comments