2021-12-02 11:01:44 +01:00
|
|
|
module zlib
|
|
|
|
|
2022-06-03 08:00:11 +02:00
|
|
|
import compress
|
2021-12-02 11:01:44 +01:00
|
|
|
|
2022-01-07 12:28:50 +01:00
|
|
|
// compresses an array of bytes using zlib and returns the compressed bytes in a new array
|
2022-05-13 05:56:21 +02:00
|
|
|
// Example: compressed := zlib.compress(b)?
|
2021-12-02 11:01:44 +01:00
|
|
|
[manualfree]
|
2022-04-15 14:35:35 +02:00
|
|
|
pub fn compress(data []u8) ?[]u8 {
|
2021-12-02 11:01:44 +01:00
|
|
|
// flags = TDEFL_WRITE_ZLIB_HEADER (0x01000)
|
2022-06-03 08:00:11 +02:00
|
|
|
return compress.compress(data, 0x01000)
|
2021-12-02 11:01:44 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 12:28:50 +01:00
|
|
|
// decompresses an array of bytes using zlib and returns the decompressed bytes in a new array
|
2022-05-13 05:56:21 +02:00
|
|
|
// Example: decompressed := zlib.decompress(b)?
|
2021-12-02 11:01:44 +01:00
|
|
|
[manualfree]
|
2022-04-15 14:35:35 +02:00
|
|
|
pub fn decompress(data []u8) ?[]u8 {
|
2021-12-02 11:01:44 +01:00
|
|
|
// flags = TINFL_FLAG_PARSE_ZLIB_HEADER (0x1)
|
2022-06-03 08:00:11 +02:00
|
|
|
return compress.decompress(data, 0x1)
|
2021-12-02 11:01:44 +01:00
|
|
|
}
|