From b1899e2bb1dd53c57c071267d21fc14075f256b1 Mon Sep 17 00:00:00 2001
From: Nikolay Kim <fafhrd91@gmail.com>
Date: Fri, 5 Oct 2018 14:29:47 -0700
Subject: [PATCH] allow to change framed codec

---
 src/codec/framed.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/codec/framed.rs b/src/codec/framed.rs
index fac1aff1..c73238bc 100644
--- a/src/codec/framed.rs
+++ b/src/codec/framed.rs
@@ -120,6 +120,19 @@ impl<T, U> Framed<T, U> {
         self.inner.into_inner().into_inner().0
     }
 
+    /// Consume the `Frame`, returning `Frame` with different codec.
+    pub fn into_framed<U2>(self, codec: U2) -> Framed<T, U2> {
+        let (inner, read_buf) = self.inner.into_parts();
+        let (inner, write_buf) = inner.into_parts();
+
+        Framed {
+            inner: framed_read2_with_buffer(
+                framed_write2_with_buffer(Fuse(inner.0, codec), write_buf),
+                read_buf,
+            ),
+        }
+    }
+
     /// Consumes the `Frame`, returning its underlying I/O stream, the buffer
     /// with unprocessed data, and the codec.
     ///