odirect
Minimal cross-platform direct I/O abstraction for Rust.
Features
- Linux:
O_DIRECT - macOS:
F_NOCACHE - Windows:
FILE_FLAG_NO_BUFFERING
Installation
[]
= "0.5.0"
Usage
use ;
Supported Access Modes
Read
Write
ReadWrite
Platform Notes
Direct/unbuffered I/O behavior differs across operating systems:
- Linux: Uses
O_DIRECTto bypass the page cache. - macOS: Uses
F_NOCACHEto disable file caching. - Windows: Uses
FILE_FLAG_NO_BUFFERINGfor unbuffered I/O.
All platforms may require aligned buffers and aligned reads/writes (typically 512 or 4096 bytes, depending on the underlying device) when performing direct I/O operations. Durability guarantees (fsync, F_FULLFSYNC, FlushFileBuffers) must be handled separately by the caller after writes.