Skip to main content

read_file_optimized

Function read_file_optimized 

Source
pub fn read_file_optimized(path: &Path, max_file_size: u64) -> Result<Vec<u8>>
Expand description

Read file contents optimally based on file size

This function chooses the optimal reading strategy based on file size:

  • Small files: Direct read with standard File I/O
  • Medium files: Memory-mapped reading for performance
  • Large files: Segmented memory-mapped reading
  • Extreme files: Windowed access with streaming

§Arguments

  • path - Path to the file to read
  • max_file_size - Maximum allowed file size

§Returns

A vector containing the file contents

§Errors

Returns an error if the file cannot be read or exceeds the size limit