summaryrefslogtreecommitdiffstats
path: root/tokio-util
diff options
context:
space:
mode:
authorOndřej Hruška <ondra@ondrovo.com>2020-05-20 21:45:03 +0200
committerGitHub <noreply@github.com>2020-05-20 21:45:03 +0200
commit456369983826cd83233a6359cfe7aaadecf7ae95 (patch)
tree1de8f8a2be2c87a0c58f608891ea72c17fcc226c /tokio-util
parentf48065910eca238d7ed644807f85c921deb12ec3 (diff)
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.
Diffstat (limited to 'tokio-util')
-rw-r--r--tokio-util/src/codec/framed.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/tokio-util/src/codec/framed.rs b/tokio-util/src/codec/framed.rs
index bf05a3ae..b23f9386 100644
--- a/tokio-util/src/codec/framed.rs
+++ b/tokio-util/src/codec/framed.rs
@@ -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