zx0decompress 0.1.2

Decompress files in the ZX0 compression format commonly used on 8 bit platforms
Documentation
  • Coverage
  • 70%
    7 out of 10 items documented1 out of 4 items with examples
  • Size
  • Source code size: 191.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 269.84 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • vilcans/zx0decompress
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vilcans

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 = std::fs::File::open(filename)?;
let content = zx0decompress::decompress(&mut source)?;

Decompress from a byte slice into a Vec<u8>:

let source = [
    0x1fu8, 0x41, 0x42, 0x52, 0x41, 0x20, 0xf6, 0xab, 0x43, 0x44, 0xf5, 0xf2, 0x55, 0x58,
];
let result = decompress(&mut source.as_ref()).unwrap();
assert_eq!(&result, b"ABRA ABRACADABRA");

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

Links