Skip to main content

Module file_io

Module file_io 

Source
Expand description

Smart file reading with memmap2 for large files. Smart file reading with automatic memmap2 for large files.

Files above MMAP_THRESHOLD are memory-mapped via the kernel page cache, then copied to a Vec<u8> because callers require ownership for mutation. For read-only use cases (e.g., checksumming), prefer crate::checksum::hash_file which operates directly on the mmap without copying.

Functions§

read_file_bytes
Read a file as raw bytes, using mmap for files above the threshold.
read_file_string
Read a file as a UTF-8 string, using mmap for files above the threshold.