Expand description
§mmap-io: High-performance memory-mapped file I/O for Rust
This crate provides a safe, efficient interface for memory-mapped file operations with support for concurrent access, segmented views, and optional async operations.
§Features
- Zero-copy I/O: Direct memory access without buffer copying
- Thread-safe: Concurrent read/write access with proper synchronization
- Segmented access: Work with file regions without loading entire files
- Cross-platform: Works on Windows, Linux, macOS via memmap2
- Async support: Optional Tokio integration for async file operations
§Quick Start
use mmap_io::{create_mmap, update_region, flush};
// Create a 1MB memory-mapped file
let mmap = create_mmap("data.bin", 1024 * 1024)?;
// Write data at offset 100
update_region(&mmap, 100, b"Hello, mmap!")?;
// Ensure data is persisted
flush(&mmap)?;
§Modules
errors
: Error types for all mmap operationsutils
: Utility functions for alignment and bounds checkingmmap
: CoreMemoryMappedFile
implementationsegment
: Segmented views for working with file regionsmanager
: High-level convenience functions
§Feature Flags
async
: Enables Tokio-based async file operations
Re-exports§
pub use errors::MmapIoError;
pub use manager::copy_mmap;
pub use manager::create_mmap;
pub use manager::delete_mmap;
pub use manager::flush;
pub use manager::load_mmap;
pub use manager::update_region;
pub use manager::write_mmap;
pub use mmap::MemoryMappedFile;
pub use mmap::MmapMode;
pub use mmap::TouchHint;
pub use advise::MmapAdvice;
pub use iterator::ChunkIterator;
pub use iterator::PageIterator;
pub use watch::ChangeEvent;
pub use watch::ChangeKind;
pub use watch::WatchHandle;
Modules§
- advise
- Memory advise operations for optimizing OS behavior.
- atomic
- Atomic memory views for lock-free concurrent access to specific data types.
- errors
- Crate-specific error types for mmap-io.
- flush
- Provides functions for flushing memory-mapped file changes to disk. Flush policy configuration for MemoryMappedFile.
- iterator
- Iterator-based access for efficient sequential processing of memory-mapped files.
- lock
- Memory locking operations to prevent pages from being swapped out.
- manager
- High-level API for managing memory-mapped files.
- mmap
- Memory-mapped file support.
- segment
- Zero-copy segment views into a memory-mapped file.
- utils
- Utility helpers for alignment, page size, and safe range calculations.
- watch
- File change watching and notification support.