Skip to main content

read_file_contents

Function read_file_contents 

Source
pub fn read_file_contents(path: &Path) -> Result<FileContents, Box<dyn Error>>
Expand description

Reads file contents, decompressing if needed.

Detection strategy:

  1. Read first 2 bytes to check magic bytes.
  2. If gzip: decompress entire file to a String.
  3. If uncompressed and < 64 KiB: read_to_string.
  4. If uncompressed and >= 64 KiB: memory-mapped I/O.