codec: add Framed::read_buffer_mut (#2546)

Adds a method to retrieve a mutable reference to the Framed stream's read buffer.
This makes it possible to e.g. externally clear the buffer to prevent the codec from
parsing stale data.
This commit is contained in:
Ondřej Hruška
2020-05-20 21:45:03 +02:00
committed by GitHub
parent f48065910e
commit 4563699838
+5
View File
@@ -195,6 +195,11 @@ impl<T, U> Framed<T, U> {
&self.inner.state.read.buffer
}
/// Returns a mutable reference to the read buffer.
pub fn read_buffer_mut(&mut self) -> &mut BytesMut {
&mut self.inner.state.read.buffer
}
/// Consumes the `Framed`, returning its underlying I/O stream.
///
/// Note that care should be taken to not tamper with the underlying stream