summaryrefslogtreecommitdiffstats
path: root/tokio-io
diff options
context:
space:
mode:
authorNikolay Kim <fafhrd91@gmail.com>2018-10-06 16:23:05 -0700
committerToby Lawrence <tobz@users.noreply.github.com>2018-10-06 19:23:05 -0400
commita2f457fa4871a9698195ab1e9f69e0af4df94e7e (patch)
tree4e1467223b7b212c3c2ac6db919170c0a544ff87 /tokio-io
parent1879bc49ce3126af4b561bfe535cbec9f7ae5b90 (diff)
io: expose underlying codec (#686)
Diffstat (limited to 'tokio-io')
-rw-r--r--tokio-io/src/_tokio_codec/framed.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tokio-io/src/_tokio_codec/framed.rs b/tokio-io/src/_tokio_codec/framed.rs
index 666bf947..614a45e2 100644
--- a/tokio-io/src/_tokio_codec/framed.rs
+++ b/tokio-io/src/_tokio_codec/framed.rs
@@ -97,6 +97,24 @@ impl<T, U> Framed<T, U> {
&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