odirect
Minimal cross-platform direct I/O abstraction for Rust.
Features
- Linux:
O_DIRECTwith optionalO_DSYNC/O_SYNC - macOS:
F_NOCACHE - Windows:
FILE_FLAG_NO_BUFFERINGwith optional write-through
Installation
[]
= "0.4.0"
Usage
use ;
Supported Access Modes
Read
Write
ReadWrite
Supported Integrity Levels
Controls durability guarantees when writing:
Null // No sync (default buffering behavior)
Data // Data integrity (Linux: O_DSYNC)
File // Full file integrity (Linux: O_SYNC)
Platform Notes
Direct/unbuffered I/O behavior differs across operating systems:
- Linux: Uses
O_DIRECT. Integrity levels map toO_DSYNCandO_SYNC. - macOS: Uses
F_NOCACHE. Integrity levels are not applied at open time—handle durability separately withfsync/F_FULLFSYNCafter writes. - Windows: Uses
FILE_FLAG_NO_BUFFERING. Integrity levels other thanNulladd write-through behavior.
Some platforms may require aligned buffers and aligned reads/writes when performing direct I/O operations.
The key changes:
- Added
Integrityto the usage example since it's now a required parameter - Added an "Integrity Levels" section
- Updated platform notes to accurately reflect how each OS handles integrity
- Kept the overall structure and simplicity intact