From f1c7d22ad3b064aa76cd2a99a5815daf95ae7f6b Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Tue, 3 May 2022 19:29:52 -0700 Subject: [PATCH] add 'get_ref()' and 'get_mut()' to 'Accept' (#104) * add 'get_ref()' and 'get_mut()' to 'Accept' * add 'get_ref()' and 'get_mut()' to 'Connect' --- tokio-rustls/src/lib.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tokio-rustls/src/lib.rs b/tokio-rustls/src/lib.rs index 242b090..6c3960a 100644 --- a/tokio-rustls/src/lib.rs +++ b/tokio-rustls/src/lib.rs @@ -308,6 +308,22 @@ impl Connect { pub fn into_fallible(self) -> FallibleConnect { FallibleConnect(self.0) } + + pub fn get_ref(&self) -> Option<&IO> { + match &self.0 { + MidHandshake::Handshaking(sess) => Some(sess.get_ref().0), + MidHandshake::Error { io, .. } => Some(io), + MidHandshake::End => None, + } + } + + pub fn get_mut(&mut self) -> Option<&mut IO> { + match &mut self.0 { + MidHandshake::Handshaking(sess) => Some(sess.get_mut().0), + MidHandshake::Error { io, .. } => Some(io), + MidHandshake::End => None, + } + } } impl Accept { @@ -315,6 +331,22 @@ impl Accept { pub fn into_fallible(self) -> FallibleAccept { FallibleAccept(self.0) } + + pub fn get_ref(&self) -> Option<&IO> { + match &self.0 { + MidHandshake::Handshaking(sess) => Some(sess.get_ref().0), + MidHandshake::Error { io, .. } => Some(io), + MidHandshake::End => None, + } + } + + pub fn get_mut(&mut self) -> Option<&mut IO> { + match &mut self.0 { + MidHandshake::Handshaking(sess) => Some(sess.get_mut().0), + MidHandshake::Error { io, .. } => Some(io), + MidHandshake::End => None, + } + } } impl Future for Connect {