Compression and decompression using gzip/zlib for Quadrate.
quadpm install https://github.com/quadrate-language/compressNote: This module requires native compilation. The C source files in src/ must be compiled and linked. Requires zlib.
use compress
fn main() {
// Compress with gzip
"Hello, World!" compress::gzip! -> compressed
// Decompress
compressed compress::gunzip! -> original
original print nl // "Hello, World!"
// Compress with specific level
"data" compress::LevelBest compress::gzip_level! -> best_compressed
// Raw deflate (no gzip header)
"data" compress::deflate! -> deflated
deflated compress::inflate! -> inflated
}
| Constant | Value | Description |
|---|---|---|
LevelFast |
1 | Fastest compression (least compression) |
LevelDefault |
6 | Default balance of speed and size |
LevelBest |
9 | Best compression (slowest) |
| Constant | Value | Description |
|---|---|---|
ErrAlloc |
2 | Memory allocation failed |
ErrInvalidArg |
3 | Invalid argument |
ErrCompress |
4 | Compression failed |
ErrDecompress |
5 | Decompression failed |
| Function | Description |
|---|---|
gzip! |
Compress with gzip format (default level) |
gzip_level! |
Compress with gzip format at specified level |
gunzip! |
Decompress gzip data |
deflate! |
Compress with raw deflate (no header) |
inflate! |
Decompress raw deflate data |
Apache-2.0 - See LICENSE for details.
Contributions welcome! Please open an issue or submit a pull request on GitHub.