Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make access inner of futures::io::{BufReader,BufWriter} not require inner trait bound #2848

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
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
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 @@ -52,7 +52,9 @@ impl<R: AsyncRead> BufReader<R> {
let buffer = vec![0; capacity];
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