Skip to content

Commit

Permalink
Make non constructor methods of futures::io::{BufReader,BufWriter} no…
Browse files Browse the repository at this point in the history
…t require inner trait bound (#2848)
  • Loading branch information
ethe authored and taiki-e committed Oct 5, 2024
1 parent e843c70 commit dffd0c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
2 changes: 2 additions & 0 deletions futures-util/src/io/buf_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ impl<R: AsyncRead> BufReader<R> {
Self { inner, buffer: buffer.into_boxed_slice(), pos: 0, cap: 0 }
}
}
}

impl<R> BufReader<R> {
delegate_access_inner!(inner, R, ());

/// Returns a reference to the internally buffered data.
Expand Down
38 changes: 20 additions & 18 deletions futures-util/src/io/buf_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ impl<W: AsyncWrite> BufWriter<W> {
Poll::Ready(ret)
}

/// Write directly using `inner`, bypassing buffering
pub(super) fn inner_poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
self.project().inner.poll_write(cx, buf)
}

/// Write directly using `inner`, bypassing buffering
pub(super) fn inner_poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<io::Result<usize>> {
self.project().inner.poll_write_vectored(cx, bufs)
}
}

impl<W> BufWriter<W> {
delegate_access_inner!(inner, W, ());

/// Returns a reference to the internally buffered data.
Expand Down Expand Up @@ -131,24 +151,6 @@ impl<W: AsyncWrite> BufWriter<W> {
this.buf.set_len(old_len + buf_len);
}
}

/// Write directly using `inner`, bypassing buffering
pub(super) fn inner_poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
self.project().inner.poll_write(cx, buf)
}

/// Write directly using `inner`, bypassing buffering
pub(super) fn inner_poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<io::Result<usize>> {
self.project().inner.poll_write_vectored(cx, bufs)
}
}

impl<W: AsyncWrite> AsyncWrite for BufWriter<W> {
Expand Down

0 comments on commit dffd0c4

Please sign in to comment.