diff --git a/monoio/src/fs/file/mod.rs b/monoio/src/fs/file/mod.rs index 0f5a29b..6a45738 100644 --- a/monoio/src/fs/file/mod.rs +++ b/monoio/src/fs/file/mod.rs @@ -1,10 +1,11 @@ -use std::{io, path::Path}; +use std::{future::Future, io, path::Path}; use crate::{ buf::{IoBuf, IoBufMut, IoVecBuf, IoVecBufMut}, driver::{op::Op, shared_fd::SharedFd}, fs::OpenOptions, io::{AsyncReadRent, AsyncWriteRent}, + BufResult, }; #[cfg(unix)] @@ -16,6 +17,8 @@ mod windows; #[cfg(windows)] use windows as file_impl; +use crate::io::{AsyncReadRentAt, AsyncWriteRentAt}; + /// A reference to an open file on the filesystem. /// /// An instance of a `File` can be read and/or written depending on what options @@ -635,6 +638,16 @@ impl AsyncWriteRent for File { } } +impl AsyncWriteRentAt for File { + fn write_at( + &mut self, + buf: T, + pos: usize, + ) -> impl Future> { + File::write_at(self, buf, pos as u64) + } +} + impl AsyncReadRent for File { /// Reads bytes from the file at the current file pointer into the specified buffer, returning /// the number of bytes read. @@ -753,3 +766,13 @@ impl AsyncReadRent for File { self.read_vectored(buf).await } } + +impl AsyncReadRentAt for File { + fn read_at( + &mut self, + buf: T, + pos: usize, + ) -> impl Future> { + File::read_at(self, buf, pos as u64) + } +}