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:
Jonathan Bastien-Filiatrault
2019-10-31 10:36:24 -04:00
committed by Lucio Franco
parent 630d3136dd
commit 2902e39db0
2 changed files with 14 additions and 0 deletions
+9
View File
@@ -79,6 +79,11 @@ impl<T, D> FramedRead<T, D> {
pub fn decoder_mut(&mut self) -> &mut D {
&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>
@@ -174,6 +179,10 @@ impl<T> FramedRead2<T> {
pub(crate) fn get_mut(&mut self) -> &mut T {
&mut self.inner
}
pub(crate) fn buffer(&self) -> &BytesMut {
&self.buffer
}
}
impl<T> Stream for FramedRead2<T>