Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/io/buf_read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ cfg_if! {
/// [`futures::io::AsyncBufRead`]:
/// https://docs.rs/futures-preview/0.3.0-alpha.17/futures/io/trait.AsyncBufRead.html
pub trait BufRead {
/// Tells this buffer that `amt` bytes have been consumed from the buffer, so they should no
/// longer be returned in calls to `read`.
fn consume(&mut self, amt: usize)
where
Self: Unpin;

/// Returns the contents of the internal buffer, filling it with more data from the inner
/// reader if it is empty.
///
Expand Down Expand Up @@ -217,7 +223,11 @@ pub trait BufRead {
}
}

impl<T: AsyncBufRead + Unpin + ?Sized> BufRead for T {}
impl<T: AsyncBufRead + Unpin + ?Sized> BufRead for T {
fn consume(&mut self, amt: usize) {
AsyncBufRead::consume(Pin::new(self), amt)
}
}

pub fn read_until_internal<R: AsyncBufRead + ?Sized>(
mut reader: Pin<&mut R>,
Expand Down