mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
Allow non-destructive access to the read buffer. (#1600)
I need this to implement SMTP pipelining checks. I mostly need to flush my send buffer when the read buffer is empty before waiting for the next command.
This commit is contained in:
parent
630d3136dd
commit
2902e39db0
@ -120,6 +120,11 @@ impl<T, U> Framed<T, U> {
|
|||||||
&mut self.inner.get_mut().get_mut().1
|
&mut self.inner.get_mut().get_mut().1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the read buffer.
|
||||||
|
pub fn read_buffer(&self) -> &BytesMut {
|
||||||
|
self.inner.buffer()
|
||||||
|
}
|
||||||
|
|
||||||
/// Consumes the `Frame`, returning its underlying I/O stream.
|
/// Consumes the `Frame`, returning its underlying I/O stream.
|
||||||
///
|
///
|
||||||
/// Note that care should be taken to not tamper with the underlying stream
|
/// Note that care should be taken to not tamper with the underlying stream
|
||||||
|
@ -79,6 +79,11 @@ impl<T, D> FramedRead<T, D> {
|
|||||||
pub fn decoder_mut(&mut self) -> &mut D {
|
pub fn decoder_mut(&mut self) -> &mut D {
|
||||||
&mut self.inner.inner.1
|
&mut self.inner.inner.1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the read buffer.
|
||||||
|
pub fn read_buffer(&self) -> &BytesMut {
|
||||||
|
&self.inner.buffer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, D> Stream for FramedRead<T, D>
|
impl<T, D> Stream for FramedRead<T, D>
|
||||||
@ -174,6 +179,10 @@ impl<T> FramedRead2<T> {
|
|||||||
pub(crate) fn get_mut(&mut self) -> &mut T {
|
pub(crate) fn get_mut(&mut self) -> &mut T {
|
||||||
&mut self.inner
|
&mut self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn buffer(&self) -> &BytesMut {
|
||||||
|
&self.buffer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Stream for FramedRead2<T>
|
impl<T> Stream for FramedRead2<T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user