Expand description
PKLib - Rust implementation of PKWare Data Compression Library
This crate provides a pure Rust implementation of the PKWare DCL format (1980s DOS era), compatible with the original PKLib by Ladislav Zezula. This format uses Huffman coding and sliding dictionary compression, and is used in game archives like MPQ and other legacy applications.
§Features
- ✅ Decompression (explode) - Full PKLib compatibility verified
- ✅ Compression (implode) - PKLib-compatible compression
- Binary and ASCII compression modes
- Dictionary sizes: 1KB, 2KB, and 4KB
- Maximum repetition length: 516 bytes
- Streaming API via Read/Write traits
- Zero-copy where possible
§Example - Decompression (Available Now)
use pklib::{explode_bytes, ExplodeReader};
use std::io::Read;
// Decompress PKLib-compressed data
let compressed_data = std::fs::read("data.imploded")?;
let decompressed = explode_bytes(&compressed_data)?;
// Or use streaming API
let mut reader = ExplodeReader::new(std::io::Cursor::new(compressed_data))?;
let mut output = Vec::new();
reader.read_to_end(&mut output)?;§Example - Compression
use pklib::{CompressionMode, DictionarySize, implode_bytes, ImplodeWriter};
use std::io::Write;
// Compress data in-memory
let data = b"Hello, World! This is a test.";
let compressed = implode_bytes(data, CompressionMode::ASCII, DictionarySize::Size2K)?;
// Or use streaming API
let mut output = Vec::new();
let mut writer = ImplodeWriter::new(&mut output, CompressionMode::ASCII, DictionarySize::Size2K)?;
writer.write_all(data)?;
let output = writer.finish()?;Re-exports§
pub use common::CompressionHeader;pub use common::CompressionMode;pub use common::CompressionStats;pub use common::DictionarySize;pub use common::PkLibError;pub use common::Result;pub use common::MAX_REP_LENGTH;pub use common::MAX_WINDOW_SIZE;pub use crc32::crc32;pub use crc32::crc32_pklib;pub use explode::explode_mpq_bytes;pub use explode::ExplodeReader;pub use implode::ImplodeWriter;
Modules§
- common
- Common types and constants for PKWare Data Compression Library
- crc32
- CRC32 implementation compatible with PKLib
- error
- Error handling for PKLib operations
- explode
- PKLib Explode (decompression) implementation
- implode
- PKLib Implode (compression) implementation
- tables
- Static lookup tables for PKWare Data Compression Library
Functions§
- explode_
bytes - Decompress data using the PKWare explode algorithm
- implode_
bytes - Compress data using the PKWare implode algorithm