zx0decompress
A Rust library to decompress files compressed with Einar Saukas' ZX0 compression format.
Normally, you use the ZX0 format to save space on 8 bit platforms like the ZX Spectrum. You compress the data on a modern computer, and use a decompressor implemented in assembly language on the target platform.
For some use cases, like build tools and other utilities, it may still be useful to have a decompressor on your workstation. That's why I created this library.
I also implemented a command-line application called zx0dec based on this library.
Usage
Add the crate to your project:
cargo add zx0decompress
Call zx0decompress::decompress with any object that implements std::io::Read.
You may also want to specify settings other than the default. For that, call zx0decompress::decompress_with_settings.
Examples
Decompress from file into a Vec<u8>:
let mut source = open?;
let content = decompress?;
Decompress from a byte slice into a Vec<u8>:
let source = ;
let result = decompress.unwrap;
assert_eq!;
Testing
In lib/tests there are compressed files (compressed with zx0-rs) and their corresponding uncompressed files. A test case verifies that zx0decompress decompresses correctly.
In the fuzz directory there are fuzz tests that can be run with cargo-fuzz:
cargo fuzz run fuzz_decompress