From 9b3f8564af4bb1aee07fab3c401eb412ca5eeac5 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Wed, 4 Sep 2019 17:45:53 -0400 Subject: [PATCH] tls: Add get_ref and get_mut (#1537) --- tokio-tls/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tokio-tls/src/lib.rs b/tokio-tls/src/lib.rs index e754c3ab585..1af689f9dff 100644 --- a/tokio-tls/src/lib.rs +++ b/tokio-tls/src/lib.rs @@ -155,6 +155,22 @@ impl TlsStream { let g = Guard(self); f(&mut (g.0).0) } + + /// Returns a shared reference to the inner stream. + pub fn get_ref(&self) -> &S + where + S: AsyncRead + AsyncWrite + Unpin, + { + &self.0.get_ref().inner + } + + /// Returns a mutable reference to the inner stream. + pub fn get_mut(&mut self) -> &mut S + where + S: AsyncRead + AsyncWrite + Unpin, + { + &mut self.0.get_mut().inner + } } impl AsyncRead for TlsStream