Skip to main content

read_file_to_string

Function read_file_to_string 

Source
pub fn read_file_to_string(path: &Path, max_file_size: u64) -> Result<String>
Expand description

Read a text file as a string using the optimal reading strategy

This function reads a file as text, using the most efficient strategy based on the file size.

§Arguments

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

§Returns

A string containing the file contents

§Errors

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