forked from mirror/async-std
implement feedback for bufreader methods
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
parent
ab0a4cb966
commit
10fedfe97f
1 changed files with 11 additions and 10 deletions
|
@ -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.
|
||||
///
|
||||
|
@ -63,15 +69,6 @@ pub trait BufRead {
|
|||
FillBufFuture::new(self)
|
||||
}
|
||||
|
||||
/// 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: AsyncBufRead + Unpin,
|
||||
{
|
||||
AsyncBufRead::consume(Pin::new(self), amt)
|
||||
}
|
||||
|
||||
/// Reads all bytes into `buf` until the delimiter `byte` or EOF is reached.
|
||||
///
|
||||
/// This function will read bytes from the underlying stream until the delimiter or EOF is
|
||||
|
@ -226,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>,
|
||||
|
|
Loading…
Reference in a new issue