diff --git a/tokio/src/fs/write.rs b/tokio/src/fs/write.rs index 2b8dd1b8d..26e5e749e 100644 --- a/tokio/src/fs/write.rs +++ b/tokio/src/fs/write.rs @@ -56,7 +56,7 @@ async fn write_uring(path: &Path, mut buf: OwnedBuf) -> io::Result<()> { .expect("unexpected in-flight operation detected") .into(); - let total: usize = buf.len(); + let total: usize = buf.as_ref().len(); let mut offset: usize = 0; while offset < total { // There is a cap on how many bytes we can write in a single uring write operation. diff --git a/tokio/src/io/uring/write.rs b/tokio/src/io/uring/write.rs index ad876d706..4f95b81bd 100644 --- a/tokio/src/io/uring/write.rs +++ b/tokio/src/io/uring/write.rs @@ -38,13 +38,13 @@ impl Op { file_offset: u64, ) -> io::Result { // Check if `buf_offset` stays in bounds of the allocation - debug_assert!(buf_offset + len as usize <= buf.len()); + debug_assert!(buf_offset + len as usize <= buf.as_ref().len()); // SAFETY: // - `buf_offset` stays in bounds of the allocation. // - `buf` is derived from an actual allocation, and the entire memory // range is in bounds of that allocation. - let ptr = unsafe { buf.as_ptr().add(buf_offset) }; + let ptr = unsafe { buf.as_ref().as_ptr().add(buf_offset) }; let sqe = opcode::Write::new(types::Fd(fd.as_raw_fd()), ptr, len) .offset(file_offset) diff --git a/tokio/src/util/as_ref.rs b/tokio/src/util/as_ref.rs index 35f7a1099..464975d60 100644 --- a/tokio/src/util/as_ref.rs +++ b/tokio/src/util/as_ref.rs @@ -7,22 +7,6 @@ pub(crate) enum OwnedBuf { Bytes(bytes::Bytes), } -impl OwnedBuf { - cfg_tokio_uring! { - pub(crate) fn len(&self) -> usize { - match self { - Self::Vec(vec) => vec.len(), - #[cfg(feature = "io-util")] - Self::Bytes(bytes) => bytes.len(), - } - } - - pub(crate) fn as_ptr(&self) -> *const u8 { - self.as_ref().as_ptr() - } - } -} - impl AsRef<[u8]> for OwnedBuf { fn as_ref(&self) -> &[u8] { match self {