pub fn read_file_safe(path: &Path) -> PatternsResult<String>Expand description
Safely read a file with size limits and UTF-8 validation.
This function:
- Validates the file path
- Checks file size against limits
- Reads the file content
- Validates UTF-8 encoding
§Arguments
path- The path to the file to read
§Returns
The file contents as a String if successful.
§Errors
PatternsError::FileNotFoundif file doesn’t existPatternsError::FileTooLargeif file exceeds MAX_FILE_SIZEPatternsError::ParseErrorif file is not valid UTF-8PatternsError::Iofor other IO errors