From a2f457fa4871a9698195ab1e9f69e0af4df94e7e Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 6 Oct 2018 16:23:05 -0700 Subject: [PATCH] io: expose underlying codec (#686) --- tokio-io/src/_tokio_codec/framed.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tokio-io/src/_tokio_codec/framed.rs b/tokio-io/src/_tokio_codec/framed.rs index 666bf9471..614a45e2b 100644 --- a/tokio-io/src/_tokio_codec/framed.rs +++ b/tokio-io/src/_tokio_codec/framed.rs @@ -97,6 +97,24 @@ impl Framed { &mut self.inner.get_mut().get_mut().0 } + /// Returns a reference to the underlying codec wrapped by + /// `Frame`. + /// + /// Note that care should be taken to not tamper with the underlying codec + /// as it may corrupt the stream of frames otherwise being worked with. + pub fn codec(&self) -> &U { + &self.inner.get_ref().get_ref().1 + } + + /// Returns a mutable reference to the underlying codec wrapped by + /// `Frame`. + /// + /// Note that care should be taken to not tamper with the underlying codec + /// as it may corrupt the stream of frames otherwise being worked with. + pub fn codec_mut(&mut self) -> &mut U { + &mut self.inner.get_mut().get_mut().1 + } + /// Consumes the `Frame`, returning its underlying I/O stream. /// /// Note that care should be taken to not tamper with the underlying stream