mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-22 16:26:46 +00:00
Merge #171
171: Add BufRead::consume r=stjepang a=yoshuawuyts Ref #131. This implements `BufReader::consume`. Thanks! Note on `fill_buf`: I couldn't get the `async fn fill_buf()` to work, but tracked progress for it here: https://gist.github.com/yoshuawuyts/09bbdc7823225ca96b5e35cd1da5d581. Got some lifetimes isssues. If anyone wants to give this a shot, please do! Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
commit
c6fecbd4ef
1 changed files with 11 additions and 1 deletions
|
@ -43,6 +43,12 @@ cfg_if! {
|
||||||
/// [`futures::io::AsyncBufRead`]:
|
/// [`futures::io::AsyncBufRead`]:
|
||||||
/// https://docs.rs/futures-preview/0.3.0-alpha.17/futures/io/trait.AsyncBufRead.html
|
/// https://docs.rs/futures-preview/0.3.0-alpha.17/futures/io/trait.AsyncBufRead.html
|
||||||
pub trait BufRead {
|
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
|
/// Returns the contents of the internal buffer, filling it with more data from the inner
|
||||||
/// reader if it is empty.
|
/// reader if it is empty.
|
||||||
///
|
///
|
||||||
|
@ -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>(
|
pub fn read_until_internal<R: AsyncBufRead + ?Sized>(
|
||||||
mut reader: Pin<&mut R>,
|
mut reader: Pin<&mut R>,
|
||||||
|
|
Loading…
Reference in a new issue