pub trait UringFile: AsRawFd {
// Required methods
async fn ur_read_at(
&self,
offset: u64,
len: u64,
) -> Result<ReadResult<Vec<u8>>>;
async fn ur_read_exact_at(&self, offset: u64, len: u64) -> Result<Vec<u8>>;
async fn ur_write_at(
&self,
offset: u64,
data: Vec<u8>,
) -> Result<WriteResult<Vec<u8>>>;
async fn ur_write_all_at(&self, offset: u64, data: &[u8]) -> Result<()>;
async fn ur_sync(&self) -> Result<()>;
async fn ur_datasync(&self) -> Result<()>;
async fn ur_statx(&self) -> Result<Metadata>;
async fn ur_fallocate(&self, offset: u64, len: u64, mode: i32) -> Result<()>;
async fn ur_fadvise(&self, offset: u64, len: u32, advice: i32) -> Result<()>;
async fn ur_ftruncate(&self, len: u64) -> Result<()>;
}Expand description
Extension trait for performing io_uring operations on file types.
This trait is implemented for std::fs::File and tokio::fs::File, allowing you to call io_uring operations directly on file handles. All operations use the global default io_uring instance. For more control, use the Uring struct directly.
Required Methods§
Sourceasync fn ur_read_at(&self, offset: u64, len: u64) -> Result<ReadResult<Vec<u8>>>
async fn ur_read_at(&self, offset: u64, len: u64) -> Result<ReadResult<Vec<u8>>>
Read from the file at the specified offset. Returns the buffer and actual bytes read. The buffer may contain fewer bytes than requested if EOF is reached.
Sourceasync fn ur_read_exact_at(&self, offset: u64, len: u64) -> Result<Vec<u8>>
async fn ur_read_exact_at(&self, offset: u64, len: u64) -> Result<Vec<u8>>
Read exactly len bytes from the file at the specified offset. Returns an error if fewer bytes are available.
Sourceasync fn ur_write_at(
&self,
offset: u64,
data: Vec<u8>,
) -> Result<WriteResult<Vec<u8>>>
async fn ur_write_at( &self, offset: u64, data: Vec<u8>, ) -> Result<WriteResult<Vec<u8>>>
Write to the file at the specified offset. Returns the original buffer and bytes written.
Sourceasync fn ur_write_all_at(&self, offset: u64, data: &[u8]) -> Result<()>
async fn ur_write_all_at(&self, offset: u64, data: &[u8]) -> Result<()>
Write all bytes to the file at the specified offset. Loops on short writes until complete.
Sourceasync fn ur_datasync(&self) -> Result<()>
async fn ur_datasync(&self) -> Result<()>
Synchronize file data to disk (fdatasync). Faster than fsync as it doesn’t sync metadata unless required.
Sourceasync fn ur_fallocate(&self, offset: u64, len: u64, mode: i32) -> Result<()>
async fn ur_fallocate(&self, offset: u64, len: u64, mode: i32) -> Result<()>
Pre-allocate or manipulate file space. Requires Linux 5.6+.
Sourceasync fn ur_fadvise(&self, offset: u64, len: u32, advice: i32) -> Result<()>
async fn ur_fadvise(&self, offset: u64, len: u32, advice: i32) -> Result<()>
Advise the kernel about file access patterns. Requires Linux 5.6+.
Sourceasync fn ur_ftruncate(&self, len: u64) -> Result<()>
async fn ur_ftruncate(&self, len: u64) -> Result<()>
Truncate the file to the specified length. Requires Linux 6.9+.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.