UringFile

Trait UringFile 

Source
pub trait UringFile: AsRawFd {
    // Required methods
    async fn ur_read_at(
        &self,
        offset: u64,
        len: u64,
    ) -> Result<ReadResult<Vec<u8>>>;
    async fn ur_write_at(
        &self,
        offset: u64,
        data: Vec<u8>,
    ) -> Result<WriteResult<Vec<u8>>>;
    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§

Source

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.

Source

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.

Source

async fn ur_sync(&self) -> Result<()>

Synchronize file data and metadata to disk (fsync).

Source

async fn ur_datasync(&self) -> Result<()>

Synchronize file data to disk (fdatasync). Faster than fsync as it doesn’t sync metadata unless required.

Source

async fn ur_statx(&self) -> Result<Metadata>

Get file metadata via statx. Requires Linux 5.6+.

Source

async fn ur_fallocate(&self, offset: u64, len: u64, mode: i32) -> Result<()>

Pre-allocate or manipulate file space. Requires Linux 5.6+.

Source

async fn ur_fadvise(&self, offset: u64, len: u32, advice: i32) -> Result<()>

Advise the kernel about file access patterns. Requires Linux 5.6+.

Source

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.

Implementations on Foreign Types§

Source§

impl UringFile for File

Source§

async fn ur_read_at(&self, offset: u64, len: u64) -> Result<ReadResult<Vec<u8>>>

Source§

async fn ur_write_at( &self, offset: u64, data: Vec<u8>, ) -> Result<WriteResult<Vec<u8>>>

Source§

async fn ur_sync(&self) -> Result<()>

Source§

async fn ur_datasync(&self) -> Result<()>

Source§

async fn ur_statx(&self) -> Result<Metadata>

Source§

async fn ur_fallocate(&self, offset: u64, len: u64, mode: i32) -> Result<()>

Source§

async fn ur_fadvise(&self, offset: u64, len: u32, advice: i32) -> Result<()>

Source§

async fn ur_ftruncate(&self, len: u64) -> Result<()>

Source§

impl UringFile for File

Source§

async fn ur_read_at(&self, offset: u64, len: u64) -> Result<ReadResult<Vec<u8>>>

Source§

async fn ur_write_at( &self, offset: u64, data: Vec<u8>, ) -> Result<WriteResult<Vec<u8>>>

Source§

async fn ur_sync(&self) -> Result<()>

Source§

async fn ur_datasync(&self) -> Result<()>

Source§

async fn ur_statx(&self) -> Result<Metadata>

Source§

async fn ur_fallocate(&self, offset: u64, len: u64, mode: i32) -> Result<()>

Source§

async fn ur_fadvise(&self, offset: u64, len: u32, advice: i32) -> Result<()>

Source§

async fn ur_ftruncate(&self, len: u64) -> Result<()>

Implementors§