mod compression¶
- module compression¶
Functions
- fn detect_compression(bytes: &[u8]) -> Compression¶
Detect compression format from the first bytes of a file.
1f 8b= gzipOtherwise = uncompressed
- fn detect_compression_from_extension(path: &Path) -> Compression¶
Detect compression format from a file extension.
Returns
Compression::Gzipfor.gzextension,Compression::Noneotherwise.
- fn gzip_writer(path: &Path) -> io::Result<flate2::write::GzEncoder<std::fs::File>>¶
Creates a gzip-compressed writer wrapping a file at the given path.
- fn read_file_contents(path: &Path) -> Result<FileContents, Box<dyn std::error::Error>>¶
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.
Enums