Expand description
Asynchronous file I/O operations with priority handling.
async_file
provides a simple yet powerful API for performing asynchronous file operations
in Rust. It closely follows the standard library’s file API design while adding async
support and priority-based scheduling.
§Features
- Async Operations: All file operations are asynchronous, allowing for non-blocking I/O
- Priority Scheduling: Every operation accepts a priority parameter for fine-grained control
- Memory Safety: Uses an opaque
Data
type to safely handle OS-managed memory allocations - Platform Agnostic: Backend-agnostic API with a default std implementation
§Quick Start
use async_file::{File, Priority};
// Open a file with unit test priority
let file = File::open("/dev/zero", Priority::unit_test()).await?;
// Read up to 1KB of data
let data = file.read(1024, Priority::unit_test()).await?;
println!("Read {} bytes", data.len());
§Design Philosophy
This library enforces that only one operation may be in-flight at a time per file handle. This constraint simplifies the implementation and prevents many classes of concurrency bugs.
The library uses opaque types (File
, Data
, Metadata
) that wrap platform-specific
implementations, providing a clean abstraction layer while maintaining efficiency.
Structs§
- Data
- An opaque buffer type that holds data read from files.
- Error
- An error that can occur during file operations.
- File
- A handle to an open file for asynchronous I/O operations.
- Metadata
- Metadata information about a file.
Functions§
- exists
- Tests if a file or directory exists at the given path.
Type Aliases§
- Priority
- A priority value for scheduling file operations.