If anyone is interested in learning gzip/deflate
Hi Rustaceans,
https://github.com/techhara/gunzip/
I wrote yet another gzip library for decompressing .gz file from scratch in safe Rust for my own educational purposes. It is only \~1000 lines of code mostly vanilla implementation, but also has some advanced features, such as multithread support and streaming API.
I have organized the branches in incremental step to make it really easy to follow along
- branch 1: main() function and skeletal structure
- branch 2: bitread module for reading bits from a byte stream
- branch 3: gzip header & footer for parsing the metadata and checksum
- branch 4: inflate for block type 0 (uncompressed) data
- branch 5: codebook and huffman\_decoder modules for decoding Huffman codes
- branch 6: lz77 and sliding\_window modules for decompressing LZ77-encoded data
- branch 7: inflate for block type 1 and 2 (compressed) data using fixed or dynamic Huffman codes
- branch 8: checksum\_write module for verifying the decompressed data
- branch 9: performance optimization
- branch 10: multithread support
- branch 11: streaming support
Though the library focuses on simplicity, it still runs faster than miniz\_oxide rust backend flate2-rs on x64 and comparable on arm64 systems. I didn't do extensive testing, so it is not production-ready, but if anyone is interested in learning gzip/deflate or want to write it from scratch, feel free to check it out.