1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-30 17:44:34 +01:00

allow to change framed codec

This commit is contained in:
Nikolay Kim 2018-10-05 14:29:47 -07:00
parent f8efabdce7
commit b1899e2bb1

View File

@ -120,6 +120,19 @@ impl<T, U> Framed<T, U> {
self.inner.into_inner().into_inner().0 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 /// Consumes the `Frame`, returning its underlying I/O stream, the buffer
/// with unprocessed data, and the codec. /// with unprocessed data, and the codec.
/// ///