Skip to content

Commit

Permalink
Merge pull request #41 from jbr/forward-async-write-for-bufreader
Browse files Browse the repository at this point in the history
Allow a BufReader that wraps an AsyncWrite to be AsyncWrite
  • Loading branch information
taiki-e committed Mar 10, 2021
2 parents 0ba0f06 15f32a4 commit ace8e58
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 701,24 @@ impl<R: AsyncSeek> AsyncSeek for BufReader<R> {
}
}

impl<R: AsyncWrite> AsyncWrite for BufReader<R> {
fn poll_write(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>> {
self.as_mut().get_pin_mut().poll_write(cx, buf)
}

fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
self.as_mut().get_pin_mut().poll_flush(cx)
}

fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
self.as_mut().get_pin_mut().poll_close(cx)
}
}

pin_project! {
/// Adds buffering to a writer.
///
Expand Down

0 comments on commit ace8e58

Please sign in to comment.