Skip to content

Commit

Permalink
add 'get_ref()' and 'get_mut()' to 'Accept' (#104)
Browse files Browse the repository at this point in the history
* add 'get_ref()' and 'get_mut()' to 'Accept'

* add 'get_ref()' and 'get_mut()' to 'Connect'
  • Loading branch information
SergioBenitez authored May 4, 2022
1 parent bcf4f8e commit f1c7d22
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tokio-rustls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,45 @@ impl<IO> Connect<IO> {
pub fn into_fallible(self) -> FallibleConnect<IO> {
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<IO> Accept<IO> {
#[inline]
pub fn into_fallible(self) -> FallibleAccept<IO> {
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<IO: AsyncRead + AsyncWrite + Unpin> Future for Connect<IO> {
Expand Down

0 comments on commit f1c7d22

Please sign in to comment.