1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! 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)
//!
//! ```no_run
//! 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)?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! # Example - Compression
//!
//! ```no_run
//! 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()?;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
// Public modules
// Async modules (only available with async feature)
// Re-export commonly used types
pub use ;
pub use ;
pub use ;
pub use ImplodeWriter;
// Re-export async types when async feature is enabled
pub use AsyncBatchProcessor;
pub use *;
pub use AsyncExplodeReader;
pub use AsyncImplodeWriter;
pub use ;
// Convenience functions
/// Compress data using the PKWare implode algorithm
///
/// # Arguments
/// * `data` - The data to compress
/// * `mode` - Compression mode (Binary or ASCII)
/// * `dict_size` - Dictionary size (1KB, 2KB, or 4KB)
///
/// # Returns
/// A vector containing the compressed data
/// Decompress data using the PKWare explode algorithm
///
/// # Arguments
/// * `data` - The compressed data
///
/// # Returns
/// A vector containing the decompressed data